Include Jekyll/Liquid code without rendering it

useful_snippet.html

{% raw %}
  {% comment %}Alot of liquid code{% endcomment %}
  {% assign toto = "Welcome to the hack !" %}
  {% assign string = "a,b,c,d" %}
  {% assign array = string | split:"," %}
  {% for item in array %}
    {{ item }}
  {% endfor %}
{% endraw %}

base display

<pre><code>{% include useful_snippet.html %}</code></pre>

display with jekyll highlight tag

{% highlight liquid %}{% include useful_snippet.html %}{% endhighlight %}

Edit: In Jekyll only process, Liquid is rendered once. So, no way to get one template doing both rendering Liquid and rendering raw Liquid code.

If you want to go that way, you'll have to use generator plugin or hooks.

Tags:

Liquid

Jekyll