Tickplate Save

Back-tick template engine for JavaScript 💬

Project README

Tickplate - Back-tick templates for JavaScript

ci status codacy snyk npm version npm downloads/month npm downloads

Usage

  • Install: npm install tickplate
  • Require: const t = require('tickplate');
  • Place tag t before templated string

Examples:

const t = require('tickplate');

const data = {
  hello: 'Ave!',
  myFriend: {
    name: 'Marcus Aurelius',
    toString() {
      return this.name;
    },
  },
  positions: ['emperor', 'philosopher', 'writer'],
};

const templ = t`${'hello'} ${'myFriend'}, great ${'positions'} of Rome`;

console.log(templ(data));
console.log(templ(data, { delimiter: ', ' }));

With default values provided (optionally):

const t = require('tickplate');

const data = {
  greeting: 'Valē!',
  person: {
    name: 'Lucius Aurelius Verus',
    toString() {
      return this.name;
    },
  },
  positions: ['brother', 'emperor', 'co-emperor'],
  ruleFrom: 161,
  ruleTo: 169,
};

const templ = t`${'greeting='} ${'person="Marcus Aurelius"'}, great ${'positions=["emperor", "philosopher"]'} of Rome from ${'ruleFrom=161'} to ${'ruleTo=180'} AD`;

console.log(templ(data));

License & Contributors

Copyright (c) 2017-2023 Metarhia contributors. Tickplate is MIT licensed.
Tickplate is a part of Metarhia technology stack.

Open Source Agenda is not affiliated with "Tickplate" Project. README Source: metarhia/tickplate
Stars
34
Open Issues
3
Last Commit
5 months ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating