Class: Liquid::Decrement
Instance Attribute Summary collapse
-
#variable_name ⇒ Object
readonly
Returns the value of attribute variable_name.
Attributes inherited from Tag
#line_number, #nodelist, #parse_context, #tag_name
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ Decrement
constructor
A new instance of Decrement.
- #render_to_output_buffer(context, output) ⇒ Object
Methods inherited from Tag
#blank?, 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) ⇒ Decrement
Returns a new instance of Decrement.
24 25 26 27 |
# File 'lib/liquid/tags/decrement.rb', line 24 def initialize(tag_name, markup, ) super @variable_name = markup.strip end |
Instance Attribute Details
#variable_name ⇒ Object (readonly)
Returns the value of attribute variable_name.
22 23 24 |
# File 'lib/liquid/tags/decrement.rb', line 22 def variable_name @variable_name end |
Instance Method Details
#render_to_output_buffer(context, output) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/liquid/tags/decrement.rb', line 29 def render_to_output_buffer(context, output) counter_environment = context.environments.first value = counter_environment[@variable_name] || 0 value -= 1 counter_environment[@variable_name] = value output << value.to_s output end |