Sha256: 1b428e3a1db360f592f69d566b12be6e96939afcca50357d88c88848cc1129f5
Contents?: true
Size: 905 Bytes
Versions: 1
Compression:
Stored size: 905 Bytes
Contents
module Liquid # Capture stores the result of a block into a variable without rendering it inplace. # # {% capture heading %} # Monkeys! # {% endcapture %} # ... # <h1>{{ heading }}</h1> # # Capture is useful for saving content for use later in your template, such as # in a sidebar or footer. # class Capture < Block Syntax = /(\w+)/ def initialize(tag_name, markup, tokens, options) if markup =~ Syntax @to = $1 else raise SyntaxError.new(options[:locale].t("errors.syntax.capture"), options[:line]) end super end def render(context) output = super context.scopes.last[@to] = output context.resource_limits[:assign_score_current] += (output.respond_to?(:length) ? output.length : 1) '' end def blank? true end end Template.register_tag('capture', Capture) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms-liquid-2.6.0 | lib/liquid/tags/capture.rb |