Class: Liquid::Rails::YieldTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/liquid-rails/tags/content_for_tag.rb

Constant Summary collapse

Syntax =
/(#{::Liquid::QuotedFragment}+)/

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, context) ⇒ YieldTag

Returns a new instance of YieldTag.



57
58
59
60
61
62
63
64
65
# File 'lib/liquid-rails/tags/content_for_tag.rb', line 57

def initialize(tag_name, markup, context)
  super

  if markup =~ Syntax
    @identifier = $1.gsub('\'', '')
  else
    raise SyntaxError.new("Syntax Error - Valid syntax: {% yield [name] %}")
  end
end

Instance Method Details

#render(context) ⇒ Object



67
68
69
70
71
# File 'lib/liquid-rails/tags/content_for_tag.rb', line 67

def render(context)
  @context = context

  @context.registers[:view].content_for(@identifier).try(:html_safe)
end