Vascula v0.1.5

Coming from Liquid

Vascula's syntax is close to Liquid's, so most templates read the same. It is its own language, stricter than Liquid in a few places. This page lists every difference.

#Behavior

LiquidVascula
Output escapingOff; use escapeAlways on; no way to turn it off
raw filter, {% raw %}AvailableNot available
Reading an unknown namePrints nothingError, unless the application allows that root
Unknown filterIgnored or error, depending on modeError
"5" > 3Compares somehowError: ordering needs two numbers or two strings
"5" == 5FalseTrue: a numeric string equals its number
10 | divided_by: 42 (integer division)2.5
IntegersArbitrary sizeExact 64-bit integers
Variables assigned in a blockGlobalGlobal (the same)
includeShares the caller's variablesRemoved; render only, with its own scope
render with a variable nameNot allowedNot allowed (the same)
and / orEvaluate right to leftEvaluate left to right, short-circuit, and return an operand
JSON inside an attributeBreaks the attributeEscaped for the attribute automatically
ErrorsOften rendered inlineReturned to the application with line and column
Resource useDepends on the hostBounded: work, output, value size, depth

#Tags

Liquid tagVascula
if, elsif, else, unlessSame. unless has no elsif.
case, whenSame, including when a, b and when a or b.
for with limit, offset, reversed, elseSame. Ranges (1..n) work.
forloop.*Same properties, including parentloop.
break, continue, cycleSame. Cycle groups (cycle "g": ...) are not supported.
assign, captureSame.
comment, {% # %}{% comment %} and {# ... #}.
increment, decrementNot supported; use assign with plus.
tablerowNot supported; use for with forloop.
liquid, echoNot supported.
renderSame idea; arguments with name: value. with and for forms are not supported.
includeNot supported.
rawNot supported.
Shopify form, section, schema, style, javascript, paginateNot part of the language; an application can add its own tags.

#Filters

These Liquid filters exist in Vascula with the same meaning: abs, append, at_least, at_most, capitalize, ceil, compact, concat, date, default, divided_by (but see the table above), downcase, escape, escape_once, first, floor, join, last, lstrip, map, minus, modulo, newline_to_br, plus, prepend, remove, remove_first, replace, replace_first, reverse, round, rstrip, size, slice, sort, sort_natural, split, strip, strip_html, strip_newlines, sum, times, truncate, truncatewords, uniq, upcase, url_decode, url_encode, where.

Vascula adds json.

Not available: raw, base64_*, url_escape, remove_last, replace_last, find, find_index, has, reject, group_by, and Shopify's commerce filters (money, img_url, t and others). Applications provide their own filters for formatting money, building URLs and translating text.

#Porting a template

  1. Compile it. Every unsupported tag or syntax error is reported with its line and column.
  2. Remove | raw and {% raw %}. If something must print HTML, the application has to pass it as trusted HTML.
  3. Replace include with render, passing what the child needs as arguments.
  4. Render it with the data it needs and fix each undeclared name error: either it is a typo, or the application must allow that root.
  5. Check divisions: unlike Liquid, divided_by does not truncate integer division; add | floor where you relied on that.