tickplate
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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.

Package Sidebar

Install

npm i tickplate

Homepage

metarhia.com

Weekly Downloads

3

Version

1.0.8

License

MIT

Unpacked Size

6.09 kB

Total Files

5

Last publish

Collaborators

  • timur.shemsedinov
  • aqrln
  • lundibundi
  • belochub
  • nechaido