New Liquid Template Features

Jonathan Rudenberg

I just pushed three new features for your liquid templating pleasure:

Raw tag

Web developers are using client-site templates like Mustache and jQuery Templates more and more these days, but they use the same curly braces as liquid, so it's hard to mix them into liquid templates. There is now a solution to this:

{% raw %}
  <h1>{{ title }}</h1>
{% endraw %}

The raw tag will render its contents verbatim, so this is the result:

<h1>{{ title }}</h1>

Read all about it on the wiki.

link.active

link.active is a new boolean that allows you to easily tell if the current page is the same as a link in a linklist.

{% for link in linklists.main-menu.links %}
<li>
   <a href="{{ link.url }}"{% if link.active %} class="active"{% endif %}>{{ link.title }}</a>
</li>
{% endfor %}

There are some nuances to it, so make sure you read the documentation on the wiki.

Alternate views

Did you know that you can make multiple versions of a template? Previously they were only selectable on a per-product basis. But now you can pick an alternate template using the url. For example, visiting http://store.myshopify.com/products/cool-kicks?view=quick will use product.quick.liquid. (Take a look at it in action on the collection page)

This works for all templates: appending ?view=foo to the URL will use template-name.foo.liquid. You can create alternate templates by clicking 'add new template' in the Template Editor.