package handlebars-ml

  1. Overview
  2. Docs

Module Handlebars_ml.CompilerSource

Sourcetype compile_error =
  1. | Missing_helper of string
    (*

    Helper function not found

    *)
  2. | Missing_partial of string
    (*

    Partial template not found

    *)
  3. | Partial_parse_error of string * Parser.parse_error
    (*

    Parsing error in a partial template

    *)
  4. | Partial_compile_error of string * compile_error
    (*

    Compilation error in a partial template

    *)

Compilation errors that can occur during template processing

Sourcetype compile_result = (string, compile_error) result

Result type for compilation operations

Sourcetype hb_error =
  1. | ParseError of Parser.parse_error
    (*

    Error during parsing

    *)
  2. | CompileError of compile_error
    (*

    Error during compilation

    *)

Combined error type for both lexing and compilation errors

Sourcetype hb_result = (string, hb_error) result

Result type for complete handlebars processing

Context values for template variables + injected extras

Sourcetype context =
  1. | Root of context_values
    (*

    Root context

    *)
  2. | Child of {
    1. values : context_values;
    2. parent : context;
    3. root : context;
    }
    (*

    Child context with parent and root reference

    *)

Template execution context with parent chain

Custom helper function type

Sourcetype custom_helper_lookup_fn = string -> custom_helper option

Function to look up custom helpers by name

Sourcetype partial_lookup_fn = string -> string option

Function to look up partial templates by name

Sourceval make_ctx : ?parent_ctx:context -> ?extras:(string * Types.literal_or_collection) List.t -> Types.literal_or_collection -> context

Create a context from a value with optional parent

Look up a value in context using an identifier path, returns `Null if not found

Evaluate an expression in a given context

Compile a list of tokens with given context and helpers

Sourceval string_of_literal : Types.literal_or_collection -> string

Convert a literal_or_collection to string representation

Sourceval escape_html : string -> string

Escape HTML entities in a string

Sourceval default_get_helper : custom_helper_lookup_fn

Default helper lookup function with built-in helpers

Sourceval default_get_partial : partial_lookup_fn

Default partial lookup function (returns None for all partials)

Sourceval compile : ?get_helper:custom_helper_lookup_fn -> ?get_partial:partial_lookup_fn -> string -> Types.literal_or_collection -> hb_result

Main compilation function