Class: Clot::IfContentFor

Inherits:
Liquid::Block
  • Object
show all
Includes:
Liquid
Defined in:
lib/clot/if_content_for.rb

Constant Summary collapse

Syntax =
/(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/

Instance Method Summary collapse

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/if_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 'yield' - Valid syntax: content_for '[template]' (with|for) [object|collection]")
  end

  super
end

Instance Method Details

#render(context) ⇒ Object



27
28
29
30
# File 'lib/clot/if_content_for.rb', line 27

def render(context)
  @template_name
  super
end