Class: Clot::IfContentFor
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Clot::IfContentFor
- Includes:
- Liquid
- Defined in:
- lib/clot/content_for.rb,
lib/clot/if_content_for.rb
Constant Summary collapse
- Syntax =
/(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ IfContentFor
constructor
A new instance of IfContentFor.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ IfContentFor
Returns a new instance of IfContentFor.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/clot/content_for.rb', line 7 def initialize(tag_name, markup, tokens) @blocks = [] if markup =~ Syntax @template_name = $1 @variable_name = $3 @attributes = {} markup.scan(TagAttributes) do |key, value| @attributes[key] = value end else raise SyntaxError.new("Syntax error in tag 'content_for' - Valid syntax: content_for '[template]' (with|for) [object|collection]") end super end |
Instance Method Details
#render(context) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/clot/content_for.rb', line 27 def render(context) if Liquid::Template.file_system.template_file_exists?( "#{context['controller_name']}/#{context['action_name']}/#{@template_name}") super else "#{context['controller_name']}/#{context['action_name']}/#{@template_name}" end end |