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

Link to this function

check_allowed_tags(rest, acc, context, line, offset, allowed_tags) View Source
check_allowed_tags(binary(), list(), tuple(), tuple(), integer(), list()) ::
  tuple()

Returns a valid tag when the tag is inside an allowed tag, else returns an error

Link to this function

close_tag(combinator \\ empty(), tag_name) View Source
close_tag(function(), binary()) :: function()

Creates a new combinator to parse the close of tags. The close of a tag is a close tag symbol %}

Link to this function

define_block(tag_name, combinator_head \\ &(&1), separator \\ " ") View Source
define_block(binary(), function(), binary()) :: function()

Creates a new combinator to parse blocks (if, for, tablerow, etc)

Link to this function

define_closed(tag_name, combinator_head \\ &(&1), combinator_body \\ &(&1), separator \\ " ") View Source
define_closed(String.t(), (... -> any()), (... -> any()), String.t()) ::
  (... -> any())

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, ""

Link to this function

define_open(tag_name, combinator_head \\ &(&1)) View Source
define_open(String.t(), (... -> any())) :: (... -> any())

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}

Link to this function

define_sub_block(tag_name, allowed_tags, combinator \\ &(&1)) View Source
define_sub_block(binary(), list(), function()) :: function()

Creates a new combinator to parse subblocks (else, elsif, when)

Link to this function

open_tag(tag_name, combinator \\ &(&1), separator \\ " ") View Source
open_tag(binary(), function(), binary()) :: function()

Creates a new combinator to parse open tags. An open tag is a open tag symbol {% and a name

Link to this function

store_tag_in_context(_, acc, context, _, _) View Source