class Liquid::Rails::ContentForTag

Constants

Syntax

Public Class Methods

new(tag_name, markup, context) click to toggle source
Calls superclass method
# File lib/liquid-rails/tags/content_for_tag.rb, line 21
def initialize(tag_name, markup, context)
  super

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

Public Instance Methods

render(context) click to toggle source
Calls superclass method
# File lib/liquid-rails/tags/content_for_tag.rb, line 32
def render(context)
  @context = context
  content  = super.html_safe

  if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 2
    if @flush == 'true'
      @context.registers[:view].view_flow.set(@identifier, content) if content
    else
      @context.registers[:view].view_flow.append(@identifier, content) if content
    end
  else
    options = @flush == 'true' ? { flush: true } : {}
    @context.registers[:view].content_for(@identifier, content, options)
  end
  ''
end