mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Updated Liquid for Programmers (markdown)
@@ -93,7 +93,7 @@ If the output of your tag depends on the arguments it was called with in the tem
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Random < Liquid::Tag
|
class RandomTag < Liquid::Tag
|
||||||
def initialize(tag_name, max, tokens)
|
def initialize(tag_name, max, tokens)
|
||||||
super
|
super
|
||||||
@max = max.to_i
|
@max = max.to_i
|
||||||
@@ -104,7 +104,7 @@ class Random < Liquid::Tag
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('random', Random)
|
Liquid::Template.register_tag('random', RandomTag)
|
||||||
```
|
```
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@@ -156,7 +156,7 @@ All tag blocks are parsed by Liquid. To create a new block, you just have to
|
|||||||
inherit from `Liquid::Block` and register your class with `Liquid::Template.register_tag`. The `register_tag` method takes two arguments: the user-facing name of the tag, and the class that implements it.
|
inherit from `Liquid::Block` and register your class with `Liquid::Template.register_tag`. The `register_tag` method takes two arguments: the user-facing name of the tag, and the class that implements it.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class Random < Liquid::Block
|
class RandomTag < Liquid::Block
|
||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
super
|
super
|
||||||
@rand = markup.to_i
|
@rand = markup.to_i
|
||||||
@@ -168,7 +168,7 @@ class Random < Liquid::Block
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('random', Random)
|
Liquid::Template.register_tag('random', RandomTag)
|
||||||
```
|
```
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
|||||||
Reference in New Issue
Block a user