Class: Liquid::Capture
- Includes:
- ParserSwitching
- Defined in:
- lib/liquid/tags/capture.rb
Constant Summary collapse
- Syntax =
/(#{VariableSignature}+)/o
Constants inherited from Block
Instance Attribute Summary collapse
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Tag
#line_number, #nodelist, #parse_context, #tag_name
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(tag_name, markup, options) ⇒ Capture
constructor
A new instance of Capture.
- #lax_parse(markup) ⇒ Object
- #render_to_output_buffer(context, output) ⇒ Object
- #strict2_parse(markup) ⇒ Object
- #strict_parse(markup) ⇒ Object
Methods included from ParserSwitching
#parse_with_selected_parser, #strict2_mode?, #strict_parse_with_error_mode_fallback
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
Constructor Details
#initialize(tag_name, markup, options) ⇒ Capture
Returns a new instance of Capture.
29 30 31 32 |
# File 'lib/liquid/tags/capture.rb', line 29 def initialize(tag_name, markup, ) super parse_with_selected_parser(markup) end |
Instance Attribute Details
#to ⇒ Object (readonly)
Returns the value of attribute to.
27 28 29 |
# File 'lib/liquid/tags/capture.rb', line 27 def to @to end |
Instance Method Details
#blank? ⇒ Boolean
60 61 62 |
# File 'lib/liquid/tags/capture.rb', line 60 def blank? true end |
#lax_parse(markup) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/liquid/tags/capture.rb', line 34 def lax_parse(markup) if markup =~ Syntax @to = Regexp.last_match(1) else raise SyntaxError, [:locale].t("errors.syntax.capture") end end |
#render_to_output_buffer(context, output) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/liquid/tags/capture.rb', line 52 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 |
#strict2_parse(markup) ⇒ Object
46 47 48 49 50 |
# File 'lib/liquid/tags/capture.rb', line 46 def strict2_parse(markup) p = @parse_context.new_parser(markup.strip) @to = p.consume(:id) p.consume(:end_of_string) end |
#strict_parse(markup) ⇒ Object
42 43 44 |
# File 'lib/liquid/tags/capture.rb', line 42 def strict_parse(markup) lax_parse(markup) end |