The region of a document enclosed by a pair of control merge fields.
Which nodes a block covers depends on where its fields sit. Fields in different table rows enclose whole rows, fields in different paragraphs enclose paragraphs, and a pair of fields inside one paragraph encloses only the runs between them. Image blocks are special: they wrap a placeholder picture rather than content to repeat.
Summary
Functions
Builds the block enclosed by the two fields, picking the block type that matches how they are laid out in the document.
The XPath selector for the element a block of this type is delimited by.
Renders a copy of the block's body with env, returning the resulting nodes.
Removes the block's body and, when no longer shared, its control fields.
Puts content in the place of the block and removes the control fields.
Types
@type t() :: %Sablon.Processor.Document.Block{ body: [Sablon.XML.Node.t()], end_field: term(), end_node: Sablon.XML.Node.t(), start_field: term(), start_node: Sablon.XML.Node.t(), type: type() }
@type type() :: :image | :row | :paragraph | :inline
Functions
Builds the block enclosed by the two fields, picking the block type that matches how they are laid out in the document.
The XPath selector for the element a block of this type is delimited by.
@spec process(t(), Sablon.Environment.t()) :: [Sablon.XML.Node.t()]
Renders a copy of the block's body with env, returning the resulting nodes.
The copy is processed in isolation so nested operations inside the block are evaluated once per iteration.
@spec remove_control_elements(t()) :: :ok
Removes the block's body and, when no longer shared, its control fields.
@spec replace(t(), [Sablon.XML.Node.t()] | struct() | nil) :: :ok
Puts content in the place of the block and removes the control fields.
For image blocks content is the image to render into the placeholder (or
nil to leave the placeholder untouched).