@tpmjs/tools-template-render
Render mustache-style templates with data. Supports {{variable}} syntax and tracks which variables were used and which were defined but unused. Optionally disable HTML escaping.
Test @tpmjs/tools-template-render (templateRenderTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-template-renderpnpm add @tpmjs/tools-template-renderyarn add @tpmjs/tools-template-renderbun add @tpmjs/tools-template-renderdeno add npm:@tpmjs/tools-template-renderimport { templateRenderTool } from '@tpmjs/tools-template-render';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { templateRenderTool } from '@tpmjs/tools-template-render';
const result = await generateText({
model: openai('gpt-4o'),
tools: { templateRenderTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
templatestringThe mustache-style template string with {{variable}} placeholders
dataobjectData object to substitute into the template
optionsobjectOptional rendering settings
Schema extracted: 1/1/2026, 8:18:42 AM
Render mustache-style templates with variable tracking.
npm install @tpmjs/tools-template-render
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"]
// Disable HTML escaping const result = await templateRenderTool.execute({ template: 'Content: {{html}}', data: { html: '<strong>Bold</strong>' }, options: { escape: false } });
{{variable}} placeholdersMIT
Downloads/month
0
Quality Score