Sha256: 67a4f4d102c29f959284510f3bd56b073610b70a161492bef672451e8f917f75
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
module Liquid # Assign sets a variable in your template. # # {% assign foo = 'monkey' %} # # You can then use the variable later in the page. # # {{ monkey }} # class Assign < Tag Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}|#{QuotedEmptyString}+)/ def initialize(tag_name, markup, tokens) 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.to_s] = context[@from] '' end end Template.register_tag('assign', Assign) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jeremyf-liquid-2.0.2 | lib/liquid/tags/assign.rb |