Liquex.Parser.Object (liquex v0.14.0)

Copy Markdown View Source

Helper methods for parsing object tags and arguments used by objects

Summary

Functions

Parse arguments. Arguments are key/value pairs, but a key may have multiple values separated by commas.

Parses closing object tag with white space removing.

Parses filter that starts with a pipe

Parse keyword field

Parses object. May contain arguments, literals, and filters.

Functions

arguments(combinator \\ empty())

@spec arguments(NimbleParsec.t()) :: NimbleParsec.t()

Parse arguments. Arguments are key/value pairs, but a key may have multiple values separated by commas.

Examples

* "img_url: '400x400', crop: 'bottom', filter: 'blur'"
* "img_size: 800, 600"

close_object_remove_whitespace(combinator \\ empty())

@spec close_object_remove_whitespace(NimbleParsec.t()) :: NimbleParsec.t()

Parses closing object tag with white space removing.

Examples

* "-}}  "

filter(combinator \\ empty())

@spec filter(NimbleParsec.t()) :: NimbleParsec.t()

Parses filter that starts with a pipe

Examples

* "| sort"
* "| at_most: 5"

keyword_field(combinator)

Parse keyword field

Examples

* "key: value"

keyword_fields(combinator \\ empty())

@spec keyword_fields(NimbleParsec.t()) :: NimbleParsec.t()

object(combinator \\ empty())

@spec object(NimbleParsec.t()) :: NimbleParsec.t()

Parses object. May contain arguments, literals, and filters.

It special cases space removing tags such as {{- and -}} to properly remove any spaces leading and trailing spaces if requested.

Examples

* "{{ 'hello world' }}"
* "{{ 5 + 5 }}"
* "{{ variable_a | at_most: 5 }}"
* "{{- my_array | sort -}}"