Sha256: 3738ae52ccb3854d6c81bf2b3628c66024c7076117100c22d32383671ca334cc
Contents?: true
Size: 677 Bytes
Versions: 2
Compression:
Stored size: 677 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*(.*)\s*/o def initialize(tag_name, markup, tokens, context) 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 def render(context) context.scopes.last[@to] = @from.render(context) '' end end Template.register_tag('assign', Assign) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotive_liquid-2.4.2 | lib/liquid/tags/assign.rb |
locomotive_liquid-2.4.1 | lib/liquid/tags/assign.rb |