Variable definitions for document templates.
Variables are {{ variable_name }} placeholders in Google Docs templates that
get substituted with actual values via the Google Docs replaceAllText API.
Summary
Functions
Builds Variable structs from a forked detection map. Text variables come first (sorted), then image variables (sorted by name).
Extracts image variable definitions from {{ image: name }} /
{{ images: name }} placeholders.
Extracts text variable names from {{ name }} placeholders.
Convenience entry point that runs both detectors and returns a forked map.
Guesses the variable type from its name.
Converts an underscore_name to a human-readable label.
Types
Functions
@spec build_definitions(%{ text: [String.t()], image: [%{name: String.t(), kind: :image | :image_list}] }) :: [t()]
Builds Variable structs from a forked detection map. Text variables come first (sorted), then image variables (sorted by name).
Extracts image variable definitions from {{ image: name }} /
{{ images: name }} placeholders.
Returns a list of %{name: String.t(), kind: :image | :image_list} maps,
deduplicated by name, sorted by name.
Note: if both {{ image: foo }} and {{ images: foo }} appear with the same name, the first occurrence (by document order) wins.
Extracts text variable names from {{ name }} placeholders.
Deliberately ignores {{ image: name }} and {{ images: name }} via a negative
lookahead — those are handled by extract_image_variables/1.
Returns a sorted list of unique names.
@spec extract_variables(term()) :: %{ text: [String.t()], image: [%{name: String.t(), kind: :image | :image_list}] }
Convenience entry point that runs both detectors and returns a forked map.
Returns %{text: [String.t()], image: [%{name, kind}]}.
@spec guess_type(String.t()) :: variable_type()
Guesses the variable type from its name.
Converts an underscore_name to a human-readable label.