Added a bit of text description to the multiply example (where we use an assignment in the custom tag code)

Oskar Pearson
2016-04-05 14:27:01 +01:00
parent d6c923163c
commit 3890e8f95b
+3 -1
@@ -108,12 +108,14 @@ Liquid::Template.register_tag('random', Random)
``` ```
```ruby ```ruby
@template = Liquid::Template.parse(" {% random 5 %}") @template = Liquid::Template.parse("{% random 5 %}")
@template.render # => "3" @template.render # => "3"
``` ```
### Using Assignments in Templates ### Using Assignments in Templates
You can also use assigned variables in your tags. To do so, use the context object passed to your render() method. In this example, we multiply any value supplied to the parameter as a tag by the configured "multiply_by" assigned value.
```ruby ```ruby
class Multiply < Liquid::Tag class Multiply < Liquid::Tag
def initialize(tag_name, factor, tokens) def initialize(tag_name, factor, tokens)