campfire.js
    Preparing search index...

    Function template

    • Creates a reusable template function from a mustache template string.

      Type Parameters

      • T extends Record<string, any> = Record<string, any>

      Parameters

      • template: string

        The template string to compile

      Returns (ctx: T) => string

      A function that accepts a context object and returns the rendered string

      const greet = template("Hello, {{ name }}!");
      const result1 = greet({ name: "Alice" }); // "Hello, Alice!"
      const result2 = greet({ name: "Bob" }); // "Hello, Bob!"