Skip to content

Liquid for programmers

harrydeluxe edited this page Mar 6, 2012 · 5 revisions

Extending Liquid

Extending Liquid is very easy. However, keep in mind that Liquid is a young library and requires some outside help. If you create useful filters and tags, please consider creating a patch and attaching it to a ticket here on this trac.

Create your own tag blocks

All tag blocks are parsed by Liquid. To create a new block, you just have to inherit from LiquidBlock and register your block with LiquidTemplate.

class LiquidTagNodisplay extends LiquidBlock
{
  public function render(&$context)
  {
     return '';
  }
}
$text = " {% nodisplay %} don't show me! {% ennodisplay %} ";
$liquid = new LiquidTemplate();
$liquid->registerTag('nodisplay', 'LiquidTagNodisplay');
$liquid->parse($text);
echo $liquid->render();  // => ""
Clone this wiki locally