[#790] Add filter to output an array into an unordered list

This commit is contained in:
Holger Just 2011-12-26 13:15:03 +01:00
parent 3c3eb2f7e7
commit 446f943968
1 changed files with 17 additions and 0 deletions

View File

@ -54,6 +54,23 @@ module ChiliProject
def strip(input)
input.to_s.strip
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
Template.register_filter(OverriddenFilters)