Sha256: ad77a808d329f0306b9d7d1098b205a86e2aec6cf0301415a45944a4a1af6bf9
Contents?: true
Size: 876 Bytes
Versions: 6
Compression:
Stored size: 876 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.increment_used_resources(:assign_score_current, output) ''.freeze end def blank? true end end Template.register_tag('capture'.freeze, Capture) end
Version data entries
6 entries across 6 versions & 1 rubygems