Sha256: 7b2093112f69cd4985ca9d4fea37ce0f1e2a76fda007b54e02fed87d3eea9341
Contents?: true
Size: 767 Bytes
Versions: 1
Compression:
Stored size: 767 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, options) if markup =~ Syntax @to = $1 @from = Variable.new($2) else raise SyntaxError.new options[:locale].t("errors.syntax.assign") end super end 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 end Template.register_tag('assign', Assign) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms-liquid-2.6.0 | lib/liquid/tags/assign.rb |