Sha256: 2dba35d658adf190c9c3d20b05ee4b934936bc4c70eb12ceb9b7984901884eb8
Contents?: true
Size: 746 Bytes
Versions: 5
Compression:
Stored size: 746 Bytes
Contents
module Liquid # Capture stores the result of a block into a variable without rendering it inplace. # # {% capture heading %} # Monkeys! # {% endcapture %} # ... # <h1>{{ monkeys }}</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) if markup =~ Syntax @to = $1 else raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]") end super end def render(context) output = super context[@to] = output.join '' end end Template.register_tag('capture', Capture) end
Version data entries
5 entries across 5 versions & 4 rubygems