Class: Liquid::Assign
Defined Under Namespace
Classes: ParseTreeVisitor
Constant Summary collapse
- Syntax =
/(#{VariableSignature}+)\s*=\s*(.*)\s*/om
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Tag
#line_number, #nodelist, #parse_context, #tag_name
Class Method Summary collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(tag_name, markup, parse_context) ⇒ Assign
constructor
A new instance of Assign.
- #render_to_output_buffer(context, output) ⇒ Object
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, parse_context) ⇒ Assign
Returns a new instance of Assign.
26 27 28 29 30 31 32 33 34 |
# File 'lib/liquid/tags/assign.rb', line 26 def initialize(tag_name, markup, parse_context) super if markup =~ Syntax @to = Regexp.last_match(1) @from = Variable.new(Regexp.last_match(2), parse_context) else self.class.raise_syntax_error(parse_context) end end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
24 25 26 |
# File 'lib/liquid/tags/assign.rb', line 24 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
24 25 26 |
# File 'lib/liquid/tags/assign.rb', line 24 def to @to end |
Class Method Details
.raise_syntax_error(parse_context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/liquid/tags/assign.rb', line 20 def self.raise_syntax_error(parse_context) raise Liquid::SyntaxError, parse_context.locale.t('errors.syntax.assign') end |
Instance Method Details
#blank? ⇒ Boolean
43 44 45 |
# File 'lib/liquid/tags/assign.rb', line 43 def blank? true end |
#render_to_output_buffer(context, output) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/liquid/tags/assign.rb', line 36 def render_to_output_buffer(context, output) val = @from.render(context) context.scopes.last[@to] = val context.resource_limits.increment_assign_score(assign_score_of(val)) output end |