Eta-based template rendering service for the Famir platform.
This package provides a shared rendering layer built on top of the Eta template engine.
The package is structured as:
src/eta-templater.ts — Eta-based templater implementation.src/index.ts - Package public exports.And exposes the following dependencies:
Templater via TEMPLATER tokennpm install @famir/templater
Example:
import { DIContainer } from '@famir/common'
import { EtaTemplater } from '@famir/templater'
// Get the global DI container instance.
const container = DIContainer.getInstance()
// Register dependency:
EtaTemplater.register(container)
Example:
import { DIContainer } from '@famir/common'
import { TEMPLATER, Templater } from '@famir/domain'
// Get the global DI container instance.
const container = DIContainer.getInstance()
// Resolve dependency:
const templater = container.resolve<Templater>(TEMPLATER)
Example:
// Renders a template string with the provided data.
const text = templater.render('Hello <%= data.name %>!', {
name: 'world',
})
console.log(text) // 'Hello world!'