-
Notifications
You must be signed in to change notification settings - Fork 297
DotLiquid for Designers
DotLiquid is intended to be as compatible as possible with the original Liquid syntax. With this in mind, we don't maintain our own template syntax documentation page; we refer you to the original Liquid for designers Liquid GitHub page, but strongly recommend you review the notes below before proceeding:
http://github.com/Shopify/liquid/wiki/Liquid-for-Designers
Any (known!) differences between DotLiquid and Liquid template syntax are noted below.
Main Article: Additional Filters
There are additional filters available in DotLiquid, over and above those specified by the Liquid syntax, take a look at the main article for details.
To suppress the line break that would normally follow the end of a tag, you can use a hyphen ("-") just before closing the tag. For example:
<ul>
{% for item in user.tasks -%}
<li>{{ item.name }}</li>
{% endfor -%}
</ul>
will result in the following output, without extra line breaks:
<ul>
<li>Documentation</li>
<li>Code comments</li>
</ul>
When using the date
filter, DotLiquid supports both Ruby and .NET date format strings (but not both at the same time). By default, it will use .NET date format strings. You can change within a template using Runtime settings, or request a global change from a Developer by setting a global property:
Liquid.UseRubyDateFormat = true;
.NET Format strings can be found here: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Using a .NET date format string within a template: {{ SomeDateField | date:"MMMM dd, yyyy" }}
Liquid by default uses Ruby casing for output fields and filters such as {{ some_field | escape }}
. DotLiquid uses this same convention by default, but can also be changed to use C# naming convention, in which case output fields and filters would be referenced like so {{ SomeField | Escape }}
.
The naming convention can only be changed by a Developer using the global setting:
Template.NamingConvention = new CSharpNamingConvention();
You can include a partial template with this tag: {% include "partial_template" %}
By naming convention this will find the _partial_template.liquid
file in the directory specified with:
Template.FileSystem = new LocalFileSystem(root); // root needs to be an absolute path