class Liquid::Assign
Assign sets a variable in your template.
{% assign foo = 'monkey' %}
You can then use the variable later in the page.
{{ foo }}
Constants
- Syntax
Public Class Methods
new(tag_name, markup, tokens)
click to toggle source
Calls superclass method
Liquid::Tag.new
# File lib/liquid/tags/assign.rb, line 14 def initialize(tag_name, markup, tokens) if markup =~ Syntax @to = $1 @from = Variable.new($2) else raise SyntaxError.new("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]") end super end
Public Instance Methods
render(context)
click to toggle source
# File lib/liquid/tags/assign.rb, line 25 def render(context) val = @from.render(context) context.scopes.last[@to] = val context.resource_limits[:assign_score_current] += (val.respond_to?(:length) ? val.length : 1) '' end