Sha256: 824181821b2100b8fdddbfbefeee409f953aade775a92ac43a2b5546bc630e16
Contents?: true
Size: 704 Bytes
Versions: 6
Compression:
Stored size: 704 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}+)/ 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
6 entries across 6 versions & 4 rubygems