Supplant
Variable substitution on string
Install / Use
/learn @bredele/SupplantREADME
Supplant
Variable substitution/interpolation on string. Look for expressions enclosed in {{ }} braces and substitutes its value with data.
Built for brick and datastore. Supplant is agnostic and can be used as a standalone template engine on both client and server sides. For example, supplant is used by marc to make markdown a dynamic template engine.
Installation
with component:
$ component install bredele/supplant
with nodejs:
$ npm install supplant
API
var Supplant = require('supplant');
var subs = new Supplant();
supplant.text(str, obj)
return the interpolation of a string with an object.
subs.text('my name is {{ name }}', {
name : 'Olivier',
});
// = > my name is Olivier
supplant.props(str)
return uniq identifiers
subs.props('hello {{ name }} and {{other}}');
// => ['name', 'other']
Advanced
Expressions
subs.text('{{ company.toUpperCase() }}', {
company : 'github'
});
//GITHUB
supplant supports grouping, binary operators, identifiers, comparators and ternary operators (see test).
Filters
subs.filter('hello', function(str) {
return 'hello ' + str;
});
subs.text('{{ company} | hello}', {
company : 'github'
});
// => hello github
License
MIT
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

