[#790] Add filter to output an array into an unordered list
This commit is contained in:
parent
3c3eb2f7e7
commit
446f943968
@ -54,6 +54,23 @@ module ChiliProject
|
|||||||
def strip(input)
|
def strip(input)
|
||||||
input.to_s.strip
|
input.to_s.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_list(array, header_or_depth = nil)
|
||||||
|
result = []
|
||||||
|
if header_or_depth.is_a?(String)
|
||||||
|
result << "\np. #{header_or_depth}\n"
|
||||||
|
depth = 1
|
||||||
|
else
|
||||||
|
if header_or_depth.respond_to?(:to_i)
|
||||||
|
depth = [1, header_or_depth.to_i].max
|
||||||
|
else
|
||||||
|
depth = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result += (array || []).collect{|elm| "#{"*" * depth.to_i } #{elm.to_s}"}
|
||||||
|
result.join("\n")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Template.register_filter(OverriddenFilters)
|
Template.register_filter(OverriddenFilters)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user