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