Class: Liquid::Capture
Overview
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.
Constant Summary collapse
- Syntax =
 /(#{VariableSignature}+)/o
Constants inherited from Block
Block::ContentOfVariable, Block::FullToken, Block::TAGSTART, Block::VARSTART
Instance Attribute Summary
Attributes inherited from Tag
#line_number, #nodelist, #options, #warnings
Instance Method Summary collapse
- #blank? ⇒ Boolean
 - 
  
    
      #initialize(tag_name, markup, options)  ⇒ Capture 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Capture.
 - #render(context) ⇒ Object
 
Methods inherited from Block
#block_delimiter, #block_name, #create_variable, #parse, #render_token_with_profiling, #unknown_tag, #warnings
Methods inherited from Tag
Methods included from ParserSwitching
Constructor Details
#initialize(tag_name, markup, options) ⇒ Capture
Returns a new instance of Capture.
      16 17 18 19 20 21 22 23  | 
    
      # File 'lib/liquid/tags/capture.rb', line 16 def initialize(tag_name, markup, ) super if markup =~ Syntax @to = $1 else raise SyntaxError.new([:locale].t("errors.syntax.capture")) end end  | 
  
Instance Method Details
#blank? ⇒ Boolean
      32 33 34  | 
    
      # File 'lib/liquid/tags/capture.rb', line 32 def blank? true end  | 
  
#render(context) ⇒ Object
      25 26 27 28 29 30  | 
    
      # File 'lib/liquid/tags/capture.rb', line 25 def render(context) output = super context.scopes.last[@to] = output context.increment_used_resources(:assign_score_current, output) ''.freeze end  |