Class: Liquid::Decrement
Overview
Hello: decrement variable %
gives you:
Hello: -1
Hello: -2
Hello: -3
Instance Attribute Summary
Attributes inherited from Tag
Instance Method Summary (collapse)
-
- (Decrement) initialize(tag_name, markup, tokens)
constructor
A new instance of Decrement.
- - (Object) render(context)
Methods inherited from Tag
Constructor Details
- (Decrement) initialize(tag_name, markup, tokens)
A new instance of Decrement
22 23 24 25 26 |
# File 'lib/liquid/tags/decrement.rb', line 22 def initialize(tag_name, markup, tokens) @variable = markup.strip super end |
Instance Method Details
- (Object) render(context)
28 29 30 31 32 33 |
# File 'lib/liquid/tags/decrement.rb', line 28 def render(context) value = context.environments.first[@variable] ||= 0 value = value - 1 context.environments.first[@variable] = value value.to_s end |