Sha256: 120d8456a72899d9082ca88d678719693d98ca469f86035de8fb2b2fc2fcac39
Contents?: true
Size: 866 Bytes
Versions: 15
Compression:
Stored size: 866 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 = /(#{VariableSignature}+)/o def initialize(tag_name, markup, options) super if markup =~ Syntax @to = $1 else raise SyntaxError.new(options[:locale].t("errors.syntax.capture")) end end def render(context) output = super context.scopes.last[@to] = output context.resource_limits.assign_score += output.length ''.freeze end def blank? true end end Template.register_tag('capture'.freeze, Capture) end
Version data entries
15 entries across 15 versions & 4 rubygems