[#790] Replace TagList and VariableList tags with variables
This commit is contained in:
parent
446f943968
commit
f1324e6af4
|
@ -40,8 +40,6 @@ module ChiliProject::Liquid
|
|||
register_tag('child_pages', ChildPages, :html => true)
|
||||
register_tag('hello_world', HelloWorld)
|
||||
register_tag('include', Include, :html => true)
|
||||
register_tag('tag_list', TagList, :html => true)
|
||||
register_tag('variable_list', VariableList, :html => true)
|
||||
|
||||
# Output these tags again as they were typed
|
||||
# These are to be handled later
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
#-- encoding: UTF-8
|
||||
#-- copyright
|
||||
# ChiliProject is a project management system.
|
||||
#
|
||||
# Copyright (C) 2010-2011 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
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
|
|
@ -1,29 +0,0 @@
|
|||
#-- encoding: UTF-8
|
||||
#-- copyright
|
||||
# ChiliProject is a project management system.
|
||||
#
|
||||
# Copyright (C) 2010-2011 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
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
|
|
@ -38,9 +38,24 @@ module ChiliProject
|
|||
@variables ||= {}
|
||||
end
|
||||
|
||||
register "tags" do
|
||||
::Liquid::Template.tags.keys.sort
|
||||
end
|
||||
|
||||
register "variables" do |context|
|
||||
vars = []
|
||||
|
||||
vars = context.environments.first.keys.reject do |var|
|
||||
# internal variable
|
||||
var == "text"
|
||||
end if context.environments.present?
|
||||
vars += context.scopes.collect(&:keys).flatten
|
||||
vars.uniq.sort
|
||||
end
|
||||
|
||||
# DEPRACATED: This is just a hint on how to use Liquid introspection
|
||||
register "macro_list",
|
||||
"Use the '{% variable_list %}' tag to see all Liquid variables and '{% tag_list %}' to see all of the Liquid tags."
|
||||
"Use '{{ variables | to_list: \"Variables:\" }}' to see all Liquid variables and '{{ tags | to_list: \"Tags:\" }}' to see all of the Liquid tags."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue