Sablon.Parser.MailMerge.Field protocol (sablon v0.4.3)

Copy Markdown View Source

The behaviour shared by simple and complex merge fields.

Fields are mutable in spirit: they are removed from the document, replaced by content, and counted as they get shared between adjacent blocks (the else field of an if block is also the start field of the else block).

Summary

Types

t()

All the types that implement this protocol.

Functions

The ancestors of the field matching selector.

The last node belonging to the field.

The merge field instruction, e.g. =title or items:each(item).

Registers one more block referencing this field.

How many blocks currently reference this field.

Removes the field, unless it is still referenced by another block.

Removes the closest ancestor matching selector, unless still referenced.

Replaces the field with rendered content.

The first node belonging to the field.

Whether the field is a well formed MERGEFIELD.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

ancestors(field, selector)

The ancestors of the field matching selector.

end_node(field)

The last node belonging to the field.

expression(field)

The merge field instruction, e.g. =title or items:each(item).

increment_reference_count(field)

Registers one more block referencing this field.

reference_count(field)

How many blocks currently reference this field.

remove(field)

Removes the field, unless it is still referenced by another block.

remove_parent(field, selector)

Removes the closest ancestor matching selector, unless still referenced.

replace(field, content, env)

Replaces the field with rendered content.

start_node(field)

The first node belonging to the field.

valid?(field)

Whether the field is a well formed MERGEFIELD.