moontemplate

    A Handlebars-style template engine in pure MoonBit

    template
    handlebars
    mustache
    html
    engine
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    3 months ago
    Downloads
    47

    No dependencies

    #MoonTemplate

    A Handlebars-style template engine for MoonBit.

    • Package: jshsj124/moontemplate
    • Version: 0.1.1
    • Repository: https://github.com/jshsj124/MoonTemplate

    See README.md for installation instructions, moon.pkg import configuration, and a complete runnable example.

    apply_helper

    fn apply_helper(name : String, value : String, helpers : Array[
    Helper
    ]) -> String?

    Apply a named helper to a value.

    compile

    fn compile(template : String) ->
    Node

    Compile a template string into an AST for reuse.

    escape_html

    fn escape_html(text : String) -> String

    Escape HTML special characters. Public for convenience.

    find_partial

    fn find_partial(name : String, partials : Array[
    Partial
    ]) -> String

    Find a partial by name in the partials array.

    render

    fn render(ast :
    Node
    , ctx : Array[(String, String)]) -> String

    Render a compiled AST with context.

    render_enhanced

    fn render_enhanced(template : String, ctx : Array[(String, String)], partials : Array[
    Partial
    ], helpers : Array[
    Helper
    ]) -> String

    Render a template with enhanced context, partials, and helpers.

    render_template

    fn render_template(template : String, ctx : Array[(String, String)]) -> String

    Render a template string with context pairs.

    Source Files