Fake Mirrors
    Preparing search index...

    Class EtaTemplater

    Eta-based templater implementation.

    Uses the lightweight and fast Eta template engine as the backend.

    https://eta.js.org - Eta template engine documentation

    import { DIContainer } from '@famir/common'
    import { TEMPLATER, Templater, EtaTemplater } from '@famir/templater'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register dependency in container
    EtaTemplater.register(container)

    // Resolve dependency from container
    const templater = container.resolve<Templater>(TEMPLATER)

    // Render simple template
    const result = templater.render(`Hello <%= data.name %>!`, { name: 'World' })
    console.log(result) // 'Hello World!'

    Implements

    • Renders a template string with the provided data.

      This method takes a template containing placeholders and a data object, and returns the rendered string with all placeholders replaced.

      Parameters

      • template: string

        The template string to render.

      • data: TemplaterData

        Key-value pairs for variable substitution.

      Returns string

      The rendered string.

      TemplaterError If template rendering fails.