Class: Liquid::Capture

### Home Classes Methods

### In Files

- lib/liquid/tags/capture.rb

### Parent

Liquid::Block

### Methods

- ::new
- #blank?
- #render

### Class/Module Index

Quicksearch

- Liquid
- Liquid::ArgumentError
- Liquid::Assign
- Liquid::BlankFileSystem
- Liquid::Block
- Liquid::Break
- Liquid::BreakInterrupt
- Liquid::Capture
- Liquid::Case
- Liquid::Comment
- Liquid::Context
- Liquid::ContextError
- Liquid::Continue
- Liquid::ContinueInterrupt
- Liquid::Cycle
- Liquid::Decrement
- Liquid::Document
- Liquid::Drop
- Liquid::ElseCondition
- Liquid::Error
- Liquid::FileSystemError
- Liquid::FilterNotFound
- Liquid::For
- Liquid::I18n
- Liquid::I18n::TranslationError
- Liquid::If
- Liquid::Ifchanged
- Liquid::Include
- Liquid::Increment
- Liquid::Interrupt
- Liquid::Lexer
- Liquid::LocalFileSystem
- Liquid::MemoryError
- Liquid::Parser
- Liquid::Raw
- Liquid::StackLevelError
- Liquid::StandardError
- Liquid::StandardFilters
- Liquid::SyntaxError
- Liquid::TableRow
- Liquid::Tag
- Liquid::Template
- Liquid::Unless
- Liquid::Utils
- Liquid::Variable
- FalseClass
- LiquidView
- Module
- NilClass
- TrueClass

No matching classes.

# Liquid::Capture

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.

### Constants

Syntax

### Public Class Methods

new(tag_name, markup, tokens) click to toggle source

    # File lib/liquid/tags/capture.rb, line 17
    def initialize(tag_name, markup, tokens)
      if markup =~ Syntax
        @to = $1
      else
        raise SyntaxError.new(options[:locale].t("errors.syntax.capture"))
      end

      super
    end

### Public Instance Methods

blank?() click to toggle source

    # File lib/liquid/tags/capture.rb, line 34
    def blank?
      true
    end

render(context) click to toggle source

    # File lib/liquid/tags/capture.rb, line 27
    def render(context)
      output = super
      context.scopes.last[@to] = output
      context.resource_limits[:assign_score_current] += (output.respond_to?(:length) ? output.length : 1)
      ''
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.