Liquid v1.0.0-alpha.1 Liquid.Combinators.Tag View Source
Helper to create tags
Link to this section Summary
Functions
Returns a valid tag when the tag is inside an allowed tag, else returns an error
Creates a new combinator to parse the close of tags.
The close of a tag is a close tag symbol %}
Creates a new combinator to parse blocks (if, for, tablerow, etc)
Define a block from a tag_name and, optionally, a function to parse tag parameters, and a function to parse the body inside the tag Both functions must receive a combinator and must return a combinator
Define a tag from a tag_name and, optionally, a function to parse tag parameters, the tag and a function to parse the body inside the tag Both functions must receive a combinator and must return a combinator
Creates a new combinator to parse subblocks (else, elsif, when)
Creates a new combinator to parse open tags.
An open tag is a open tag symbol {% and a name
Link to this section Functions
check_allowed_tags(rest, acc, context, line, offset, allowed_tags) View Source
Returns a valid tag when the tag is inside an allowed tag, else returns an error
close_tag(combinator \\ empty(), tag_name) View Source
Creates a new combinator to parse the close of tags.
The close of a tag is a close tag symbol %}
define_block(tag_name, combinator_head \\ &(&1), separator \\ " ") View Source
Creates a new combinator to parse blocks (if, for, tablerow, etc)
define_closed(tag_name, combinator_head \\ &(&1), combinator_body \\ &(&1), separator \\ " ") View Source
Define a block from a tag_name and, optionally, a function to parse tag parameters, and a function to parse the body inside the tag Both functions must receive a combinator and must return a combinator
The returned tag is a combinator which expect a start tag {% a tag name and a end tag %}
Examples
Tag.define_closed( "comment", & &1, fn combinator -> combinator |> optional(parsec(:comment_content)) |> reduce({Markup, :literal, []}) end, ""
define_open(tag_name, combinator_head \\ &(&1)) View Source
Define a tag from a tag_name and, optionally, a function to parse tag parameters, the tag and a function to parse the body inside the tag Both functions must receive a combinator and must return a combinator
The returned tag is a combinator which expect a start tag {% a tag name and a end tag %}
Examples
defmodule MyParser do import NimbleParsec alias Liquid.Combinators.Tag
def ignorable, do: Tag.define_closed( "ignorable", fn combinator -> combinator |> string("T") |> ignore() |> integer(2,2))
MyParser.ignorable("{% ignorable T12 %}") #=> {:ok, {:ignorable, [12]}, "", %{}, {1, 0}, 2}
define_sub_block(tag_name, allowed_tags, combinator \\ &(&1)) View Source
Creates a new combinator to parse subblocks (else, elsif, when)
open_tag(tag_name, combinator \\ &(&1), separator \\ " ") View Source
Creates a new combinator to parse open tags.
An open tag is a open tag symbol {% and a name