mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
c886738bbc
- Try to make sure it's clear how to make interpolation work when working with handlebars helpers |
||
---|---|---|
.. | ||
lib | ||
test | ||
.eslintrc.js | ||
index.js | ||
LICENSE | ||
package.json | ||
README.md |
Tpl
Install
npm install @tryghost/tpl --save
or
yarn add @tryghost/tpl
Usage
const tpl = require('@tryghost/tpl');
messages = {
myError: 'Something terrible happened to {something}'
};
console.error(tpl(messages.myError, {something: 'The thing'}));
- Takes strings like 'Your site is now available on {url}' and interpolates them with passed in data
- Will ignore double or triple braces like {{get}} or {{{content}}}
- Can handle escaped braces e.g. \\{\\{{helpername}\\}\\}
- There's a simple bare minimum escaping needed to make {{{helpername}}} work with interpolation e.g. {\\{{helpername}}}
Develop
This is a mono repository, managed with lerna.
Follow the instructions for the top-level repo.
git clone
this repo &cd
into it as usual- Run
yarn
to install top-level dependencies.
Run
yarn dev
Test
yarn lint
run just eslintyarn test
run lint and tests
Copyright & License
Copyright (c) 2013-2021 Ghost Foundation - Released under the MIT license.