Class: Solid::LiquidExtensions::IfTag
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Solid::LiquidExtensions::IfTag
- Extended by:
- TagHighjacker
- Includes:
- Element
- Defined in:
- lib/solid/liquid_extensions/if_tag.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(tag_name, expression, tokens, context = {}) ⇒ IfTag
constructor
A new instance of IfTag.
- #render(context) ⇒ Object
- #unknown_tag(tag, expression, tokens, context = {}) ⇒ Object
Methods included from TagHighjacker
Methods included from Element
#arguments, #current_context, #display, included, #with_context
Constructor Details
#initialize(tag_name, expression, tokens, context = {}) ⇒ IfTag
Returns a new instance of IfTag.
9 10 11 12 13 |
# File 'lib/solid/liquid_extensions/if_tag.rb', line 9 def initialize(tag_name, expression, tokens, context = {}) @blocks = [] push_block!(expression) super end |
Instance Method Details
#render(context) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/solid/liquid_extensions/if_tag.rb', line 15 def render(context) with_context(context) do @blocks.each do |expression, blocks| if expression.evaluate(context) return render_all(blocks, context) end end end '' end |
#unknown_tag(tag, expression, tokens, context = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/solid/liquid_extensions/if_tag.rb', line 26 def unknown_tag(tag, expression, tokens, context = {}) if tag == 'elsif' push_block!(expression) elsif tag == 'else' push_block!('true') end end |