Mustache helpers

Mustache TemplateDelimiter configuration and operation renderers for HTML previews and Markdown export.

Pass MUSTACHE as templates=MUSTACHE to parse_md or md2mdhtml, paired with mustache_pill for HTML preview badges or mustache_text / mustache_code for Markdown serialization.

op = {"syntax": "mustache", "action": "var", "name": "client", "form": "inline"}
assert mustache_text(op) == "{{client}}" and mustache_code(op) == "`{{client}}`"

mustache_pill

def mustache_pill(
    node:dict, # Semantic operation dict (`syntax`, `action`, `name`, `form`, optional `columns`)
    html:str, # Default MDHTML for the node (unused; required by the `callbacks['operation']` signature)
)->str | None: # Styled HTML `<span>` (or `<tr>` for row operations), or `None` for non-Mustache operations

Render a Mustache operation as a styled HTML pill in previews.

mustache_text

def mustache_text(
    node:dict, # Semantic operation dict (`action`, `name`)
)->str: # Canonical Mustache token text (e.g. `'{{name}}'` or `'{{#items}}'`)

Render a semantic Mustache operation in canonical Mustache spelling.

mustache_code

def mustache_code(
    node:dict, # Semantic operation dict (`action`, `name`)
)->str: # Markdown inline code span wrapping `mustache_text(node)`

Render a semantic Mustache operation as a literal Markdown code span.