Skip to content
A reference implementation for Simple token replacement template.
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
test
.gitignore
.travis.yml
LICENSE
README.md
package.json
tsconfig.json

README.md

simple-token-replacement-template Build Status

A reference implementation for Simple token replacement template.

There are three major “levels” of functionality in templating languages.

  • Simple Token Replacement
  • Limited Control Structures
  • Programming Language

Three Levels Templates

Install

Install with npm:

npm install simple-token-replacement-template

Usage

Compile template with values.

import { compileTemplate } from "simple-token-replacement-template";
const result = compileTemplate(`Your name is {{name}}. Your age is {{age}}.`, {
    name: "tom",
    age: "18"
});
assert.strictEqual(result, `Your name is tom. Your age is 18.`);

If missing variable is put, pass through it as string.

import { compileTemplate } from "simple-token-replacement-template";
const result = compileTemplate(`{{missing}}`, {});
assert.strictEqual(result, `{{missing}}`);

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

You can’t perform that action at this time.