Parent

Liquid::If

If is the conditional block

{% if user.admin %}
  Admin user!
{% else %}
  Not admin user
{% endif %}

 There are {% if count < 5 %} less {% else %} more {% endif %} items than you need.

Public Class Methods

new(tag_name, markup, tokens) click to toggle source
# File lib/liquid/tags/if.rb, line 19
def initialize(tag_name, markup, tokens)
  @blocks = []

  push_block('if', markup)

  super
end

Public Instance Methods

render(context) click to toggle source
# File lib/liquid/tags/if.rb, line 35
def render(context)
  context.stack do
    @blocks.each do |block|
      if block.evaluate(context)
        return render_all(block.attachment, context)
      end
    end
    ''
  end
end
unknown_tag(tag, markup, tokens) click to toggle source
# File lib/liquid/tags/if.rb, line 27
def unknown_tag(tag, markup, tokens)
  if ['elsif', 'else'].include?(tag)
    push_block(tag, markup)
  else
    super
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.