Class: Solid::LiquidExtensions::AssignTag

Inherits:
Tag
  • Object
show all
Extended by:
TagHighjacker
Defined in:
lib/solid/liquid_extensions/assign_tag.rb

Instance Method Summary collapse

Methods included from TagHighjacker

load!, tag_name, unload!

Methods inherited from Tag

#render

Methods included from Element

#arguments, #current_context, included, #with_context

Constructor Details

#initialize(tag_name, assignment, tokens, context = {}) ⇒ AssignTag

Returns a new instance of AssignTag.



8
9
10
11
12
# File 'lib/solid/liquid_extensions/assign_tag.rb', line 8

def initialize(tag_name, assignment, tokens, context = {})
  @assigned_variable, expression = assignment.split('=', 2)
  @assigned_variable = @assigned_variable.strip
  super(tag_name, expression, tokens, context)
end

Instance Method Details

#display(expression_result) ⇒ Object



14
15
16
17
# File 'lib/solid/liquid_extensions/assign_tag.rb', line 14

def display(expression_result)
  current_context.scopes.last[@assigned_variable] = expression_result
  ''
end