Sha256: 143e184c54f268fd922792c30d19a9ce5419229cacbded45a74f275bb845fc74
Contents?: true
Size: 668 Bytes
Versions: 3
Compression:
Stored size: 668 Bytes
Contents
module Liquid # Assign sets a variable in your template. # # {% assign foo = 'monkey' %} # # You can then use the variable later in the page. # # {{ foo }} # class Assign < Tag Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}+)/ def initialize(tag_name, markup, tokens, context) if markup =~ Syntax @to = $1 @from = $2 else raise SyntaxError.new("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]") end super end def render(context) context.scopes.last[@to] = context[@from] '' end end Template.register_tag('assign', Assign) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
locomotive_liquid-2.2.3 | lib/liquid/tags/assign.rb |
locomotive_liquid-2.2.2 | lib/liquid/tags/assign.rb |
locomotive_liquid-2.1.3 | lib/liquid/tags/assign.rb |