Mechanic's Liquid implementation includes three new literals:

  • newline"\n"
  • hash{} 
  • array[] 

Use newline  to more easily navigate strings, and hash and array to quickly construct your own data structures.

Because these are literals, these keywords cannot be overwritten as variables.

Hash and array

These literals may be used for initializing variables, and then assigning within them. Learn more about the assign tag.

Newline

Besides its natural uses in building strings, newline has a special purpose within these string filters:

  • newline_to_br – When used with newline, this filter will replace instances of "\r\n", and then instances of "\n".
  • replace – When used with newline as its first argument, this filter will replace instances of "\r\n", and then instances of "\n".
  • split – When used with newline, this filter will split by "\r\n" when present, and then by "\n".

Technical note: Under the hood, each of these scenarios uses the regular expression /\r?\n/.

Did this answer your question?