Sha256: c5b3abfffef23c9cb926aea92eb3f91f0a4a5e04c467284b21bca4b519ada70a
Contents?: true
Size: 758 Bytes
Versions: 36
Compression:
Stored size: 758 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) 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.scopes.last[@to] = output.join '' end end Template.register_tag('capture', Capture) end
Version data entries
36 entries across 36 versions & 4 rubygems