Class: Liquid::Capture

Inherits:
Block show all
Defined in:
lib/liquid/tags/capture.rb

Constant Summary collapse

Syntax =
/(#{VariableSignature}+)/o

Constants inherited from Block

Block::MAX_DEPTH

Instance Attribute Summary

Attributes inherited from Tag

#line_number, #nodelist, #parse_context, #tag_name

Instance Method Summary collapse

Methods inherited from Block

#block_delimiter, #block_name, #nodelist, #parse, #raise_tag_never_closed, raise_unknown_tag, #render, #unknown_tag

Methods inherited from Tag

disable_tags, #name, parse, #parse, #raw, #render

Methods included from ParserSwitching

#parse_with_selected_parser, #strict_parse_with_error_mode_fallback

Constructor Details

#initialize(tag_name, markup, options) ⇒ Capture

Returns a new instance of Capture.



21
22
23
24
25
26
27
28
# File 'lib/liquid/tags/capture.rb', line 21

def initialize(tag_name, markup, options)
  super
  if markup =~ Syntax
    @to = Regexp.last_match(1)
  else
    raise SyntaxError, options[:locale].t("errors.syntax.capture")
  end
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/liquid/tags/capture.rb', line 38

def blank?
  true
end

#render_to_output_buffer(context, output) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/liquid/tags/capture.rb', line 30

def render_to_output_buffer(context, output)
  context.resource_limits.with_capture do
    capture_output = render(context)
    context.scopes.last[@to] = capture_output
  end
  output
end