Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 765 Bytes

filter-liquid-in-front-matter.md

File metadata and controls

40 lines (28 loc) · 765 Bytes
layout title
snippet
liquify Filter - Use Liquid Placeholders in Front Matter Values

{{ page.title }}

Add a new filter that lets you use liquid in your front matter block. Example:

---
title: How to install {% raw %}{{ site.data.placeholder.product-name }}{% endraw %}
---

And the filter:

module LiquidFilter
  def liquify(input)
    Liquid::Template.parse(input).render(@context)
  end
end
Liquid::Template.register_filter(LiquidFilter)

Use it in your templates / layouts like:

{% raw %}
{{ page.title | liquify }}
{% endraw %}

Sources