From 3890e8f95b21a3be65b9dbf4f229f871b836e1aa Mon Sep 17 00:00:00 2001 From: Oskar Pearson Date: Tue, 5 Apr 2016 14:27:01 +0100 Subject: [PATCH] Added a bit of text description to the multiply example (where we use an assignment in the custom tag code) --- Liquid-for-Programmers.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Liquid-for-Programmers.md b/Liquid-for-Programmers.md index 06e2ad8..f1373d2 100644 --- a/Liquid-for-Programmers.md +++ b/Liquid-for-Programmers.md @@ -108,12 +108,14 @@ Liquid::Template.register_tag('random', Random) ``` ```ruby -@template = Liquid::Template.parse(" {% random 5 %}") +@template = Liquid::Template.parse("{% random 5 %}") @template.render # => "3" ``` ### 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 class Multiply < Liquid::Tag def initialize(tag_name, factor, tokens)