DotLiquid for Designers

dumky edited this page Jul 30, 2015 · 11 revisions

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:

Any (known!) differences between DotLiquid and Liquid template syntax are noted below.

Line breaks

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:

{% for item in user.tasks -%}
  <li>{{ }}</li>
{% endfor -%}

will result in the following output, without extra line breaks:

  <li>Code comments</li>

Date format strings

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. This can be changed by setting a configuration property:

Liquid.UseRubyDateFormat = true;

.NET Format strings can be found here:

Using a .NET date format string within a template: {{ SomeDateField | date:"MMMM dd, yyyy" }}

Filter and Output Casing

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 }}


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