Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/metarhia/tickplate

Back-tick template engine for JavaScript πŸ’¬
https://github.com/metarhia/tickplate

console format formatter html impress javascript metarhia nodejs render renderer strings template templating tick

Last synced: 3 days ago
JSON representation

Back-tick template engine for JavaScript πŸ’¬

Awesome Lists containing this project

README

        

## Tickplate - Back-tick templates for JavaScript

[![ci status](https://github.com/metarhia/tickplate/workflows/Testing%20CI/badge.svg)](https://github.com/metarhia/tickplate/actions?query=workflow%3A%22Testing+CI%22+branch%3Amaster)
[![codacy](https://api.codacy.com/project/badge/Grade/69719502402b43598ffac0fd35f2192c)](https://www.codacy.com/app/metarhia/tickplate)
[![snyk](https://snyk.io/test/github/metarhia/tickplate/badge.svg)](https://snyk.io/test/github/metarhia/tickplate)
[![npm version](https://badge.fury.io/js/tickplate.svg)](https://badge.fury.io/js/tickplate)
[![npm downloads/month](https://img.shields.io/npm/dm/tickplate.svg)](https://www.npmjs.com/package/tickplate)
[![npm downloads](https://img.shields.io/npm/dt/tickplate.svg)](https://www.npmjs.com/package/tickplate)

## Usage

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

## Examples:

```js
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):

```js
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](https://github.com/metarhia/tickplate/graphs/contributors).
Tickplate is [MIT licensed](./LICENSE).\
Tickplate is a part of [Metarhia](https://github.com/metarhia) technology stack.