Browse files

Add documentation for custom tag blocks (#7359)

Merge pull request 7359
  • Loading branch information...
pravan authored and jekyllbot committed Nov 7, 2018
1 parent 9a66a16 commit 7d76d5e48e47514e819c5eca57ef40ebe7047778
Showing with 43 additions and 0 deletions.
  1. +43 −0 docs/_docs/plugins/
@@ -70,3 +70,46 @@ And we would get something like this on the page:
<p>page rendered at: Tue June 22 23:38:47 –0500 2010</p>
## Tag Blocks
The `render_time` tag seen above can also be rewritten as a tag block by
inheriting the `Liquid::Block` class. Look at the example below:
module Jekyll
class RenderTimeTagBlock < Liquid::Block
def render(context)
text = super
"<p>#{text} #{}</p>"
Liquid::Template.register_tag('render_time', Jekyll::RenderTimeTagBlock)
We can now use the tag block anywhere:
{% raw %}
{% render_time %}
page rendered at:
{% endrender_time %}
{% endraw %}
And we would still get the same output as above on the page:
<p>page rendered at: Tue June 22 23:38:47 –0500 2010</p>
<div class="note info">
<p>In the above example, the tag block and the tag are both registered with
the name <code>render_time</code> but to register a tag and a tag block using
the same name in the same project is not recommended as this may lead to

0 comments on commit 7d76d5e

Please sign in to comment.