tpmjs/packages/tools/official/template-render
Ajax Davis 5926373be6 chore: update ai package to 6.0.49 across all packages
- Updated all packages from ai@6.0.23 to ai@6.0.49
- Added pnpm override to ensure consistent version
- Created changeset for publishing affected packages
2026-01-25 11:33:03 +10:00
..
src feat: add use cases marketing product with AI-generated content 2026-01-20 16:17:35 +10:00
CHANGELOG.md chore: version packages 2025-12-31 23:54:47 +10:00
package.json chore: update ai package to 6.0.49 across all packages 2026-01-25 11:33:03 +10:00
README.md feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsconfig.json feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsup.config.ts feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00

@tpmjs/tools-template-render

Render mustache-style templates with variable tracking.

Installation

npm install @tpmjs/tools-template-render

Usage

import { templateRenderTool } from '@tpmjs/tools-template-render';

const result = await templateRenderTool.execute({
  template: 'Hello {{name}}! Your score is {{score}}.',
  data: {
    name: 'Alice',
    score: 95,
    unused: 'extra data'
  }
});

console.log(result.rendered);
// => "Hello Alice! Your score is 95."

console.log(result.variablesUsed);
// => ["name", "score"]

console.log(result.unusedVariables);
// => ["unused"]

Options

// Disable HTML escaping
const result = await templateRenderTool.execute({
  template: 'Content: {{html}}',
  data: { html: '<strong>Bold</strong>' },
  options: { escape: false }
});

Features

  • Mustache syntax: Uses standard {{variable}} placeholders
  • Variable tracking: Reports which variables were used and which were provided but unused
  • HTML escaping: Automatically escapes HTML by default (can be disabled)
  • Nested data: Supports nested object access with dot notation

License

MIT