Modules@robinpath/template
@robinpath/template
0.1.0PublicMustache-like template engine with variable substitution, conditional sections, loops, and simple string interpolation
@robinpath/template
Mustache-like template engine with variable substitution, conditional sections, loops, and simple string interpolation
Why use this module?
The template module lets you:
- Render a Mustache-like template string with variable substitution, sections, and loops
- Read a template from a file and render it with the provided data object
- HTML-escape a string, converting &, <, >, ", and ' to their HTML entity equivalents
- Validate template syntax, checking for unclosed tags, mismatched sections, and other structural errors
- Extract all unique variable and section names used in a template
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/template
Quick Start
No credentials needed — start using it right away:
template.renderFile "/tmp/greeting.mustache" { "name": "World" }
Available Functions
| Function | Description |
|---|---|
template.render | Render a Mustache-like template string with variable substitution, sections, and loops |
template.renderFile | Read a template from a file and render it with the provided data object |
template.escape | HTML-escape a string, converting &, <, >, ", and ' to their HTML entity equivalents |
template.compile | Validate template syntax, checking for unclosed tags, mismatched sections, and other structural errors |
template.extractVariables | Extract all unique variable and section names used in a template |
template.renderString | Simple string interpolation using ${key} placeholders (no sections or loops) |
Examples
Read a template from a file and render it with the provided data object
template.renderFile "/tmp/greeting.mustache" { "name": "World" }
HTML-escape a string, converting &, <, >, ", and ' to their HTML entity equivalents
template.escape "<script>alert(1)</script>"
Validate template syntax, checking for unclosed tags, mismatched sections, and other structural errors
template.compile "{{#items}}{{name}}{{/items}}"
Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/template";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
template.renderFile "/tmp/greeting.mustache" { "name": "World" }
`);
Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.0 | latest | yesterday |
Related Modules
utilities
1
@dev-tester/hello-world
v2.0.0dev-tester
Updated description
0 downloads
...
utilities
0
@robinpath/apollo
v0.1.1robinpath
Apollo module for RobinPath.
0 downloads
...
utilities
0
@robinpath/archive
v0.1.1robinpath
Create and extract .zip and .tar.gz file archives
0 downloads
...
utilities
0
@robinpath/assert
v0.1.1robinpath
Testing assertions: equal, deepEqual, truthy, falsy, type checks, includes, matches, throws, and more
0 downloads
...
Install
$ robinpath install @robinpath/template Version0.1.0
LicenseMIT
Unpacked Size5.9 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

