@nubond/posthtml-value-interpolation
v1.0.2
Published
PostHTML plugin for Parcel that compiles mustache-style {{ expression }} templates into nuBond nb-value bindings at build time
Maintainers
Readme
What it does
Write Mustache-style templates:
<h1>Hello, {{ this.name }}!</h1>The plugin emits nuBond-native bindings:
<h1>Hello, <span nb-value=" this.name "></span>!</h1>Installation
If you scaffolded your project from
npm create nubond, this plugin is already wired up — no need to do anything.
- Install the package:
npm install --save-dev @nubond/posthtml-value-interpolationAdd a
.posthtmlrcfile to the root of your Parcel project.Place the following content in the file:
{
"plugins": {
"@nubond/posthtml-value-interpolation": {}
}
}Or use it directly with PostHTML:
import posthtml from 'posthtml';
import valueInterpolation from '@nubond/posthtml-value-interpolation';
const { html } = await posthtml([valueInterpolation()])
.process('<div>{{ this.user.name }}</div>');Supported expressions
Anything between {{ … }} is passed verbatim into nb-value, so the full nuBond expression grammar works — member access, method calls, ternaries, template literals, repeat-scope vars, expression prefixes (#, @), etc.
The plugin only transforms text nodes — HTML attributes (<div class="{{ x }}">), <script>/<style> blocks, and unmatched braces are left untouched.
License
MIT © Dmytro Tomayly
