[#604] Port the macro_list to Liquid: variable_list and tag_list
This commit is contained in:
parent
7778ff2f83
commit
1e7dfe545e
|
@ -27,7 +27,8 @@ module ChiliProject::Liquid
|
|||
# child_pages
|
||||
register_tag('hello_world', HelloWorld)
|
||||
# include
|
||||
# macro_list
|
||||
register_tag('tag_list', TagList, :html => true)
|
||||
register_tag('variable_list', VariableList, :html => true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module ChiliProject::Liquid::Tags
|
||||
class TagList < Tag
|
||||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def render(context)
|
||||
content_tag('p', "Tags:") +
|
||||
content_tag('ul',
|
||||
::Liquid::Template.tags.keys.sort.collect {|tag_name|
|
||||
content_tag('li', content_tag('code', h(tag_name)))
|
||||
}.join('')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
module ChiliProject::Liquid::Tags
|
||||
class VariableList < Tag
|
||||
include ActionView::Helpers::TagHelper
|
||||
|
||||
def render(context)
|
||||
out = ''
|
||||
context.environments.first.keys.sort.each do |liquid_variable|
|
||||
next if liquid_variable == 'text' # internal variable
|
||||
out << content_tag('li', content_tag('code', h(liquid_variable)))
|
||||
end if context.environments.present?
|
||||
|
||||
content_tag('p', "Variables:") + content_tag('ul', out)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ module ChiliProject
|
|||
# Variables are used in liquid like {{var}}
|
||||
def self.macro_backwards_compatibility
|
||||
{
|
||||
'macro_list' => "Use the '{% variable_list %}' tag to see all Liquid variables and '{% tag_list %}' to see all of the Liquid tags."
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,16 +68,6 @@ module Redmine
|
|||
end
|
||||
|
||||
# Builtin macros
|
||||
desc "Displays a list of all available macros, including description if available."
|
||||
macro :macro_list do
|
||||
out = ''
|
||||
@@available_macros.keys.collect(&:to_s).sort.each do |macro|
|
||||
out << content_tag('dt', content_tag('code', macro))
|
||||
out << content_tag('dd', textilizable(@@available_macros[macro.to_sym]))
|
||||
end
|
||||
content_tag('dl', out)
|
||||
end
|
||||
|
||||
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" +
|
||||
" !{{child_pages}} -- can be used from a wiki page only\n" +
|
||||
" !{{child_pages(Foo)}} -- lists all children of page Foo\n" +
|
||||
|
|
Loading…
Reference in New Issue