diff --git a/Liquid-for-Programmers.textile b/Liquid-for-Programmers.textile index 38eae97..e4e9ac4 100644 --- a/Liquid-for-Programmers.textile +++ b/Liquid-for-Programmers.textile @@ -5,8 +5,8 @@ A Liquid template is rendered in two steps: Parse and Render. For an overview of the Liquid syntax, please read [[Liquid for Designers]].
- @template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
- @template.render( 'name' => 'tobi' ) # Renders the output => "hi tobi"
+@template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
+@template.render( 'name' => 'tobi' ) # Renders the output => "hi tobi"
The @parse@ step creates a fully compiled template which can be re-used as often as you like.
@@ -65,17 +65,17 @@ h3. Create your own tags
To create a new tag, simply inherit from @Liquid::Tag@ and register your block with @Liquid::Template@.
- class Random < Liquid::Tag
- def initialize(tag_name, max, tokens)
- super
- @max = max.to_i
- end
-
- def render(context)
- rand(@max).to_s
- end
+class Random < Liquid::Tag
+ def initialize(tag_name, max, tokens)
+ super
+ @max = max.to_i
end
+ def render(context)
+ rand(@max).to_s
+ end
+end
+
Liquid::Template.register_tag('random', Random)
@@ -91,21 +91,21 @@ To create a new block,
you just have to inherit from @Liquid::Block@ and register your block with @Liquid::Template@.
- class Random < Liquid::Block
- def initialize(tag_name, markup, tokens)
- super
- @rand = markup.to_i
- end
-
- def render(context)
- if rand(@rand) == 0
- super
- else
- ''
- end
- end
+class Random < Liquid::Block
+ def initialize(tag_name, markup, tokens)
+ super
+ @rand = markup.to_i
end
+ def render(context)
+ if rand(@rand) == 0
+ super
+ else
+ ''
+ end
+ end
+end
+
Liquid::Template.register_tag('random', Random)