0.0.9 • Published 2 years ago

robojournalist v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

robojournalist

A simple template system

Install

$ npm install robojournalist

Usage

import robojournalist from 'robojournalist';

robojournalist('The value of a is {a}.', {a: 'b'});
//=> 'The value of a is b.'

robojournalist('The value of a.b is {a.b}.', {a: {b: 'c'}});
//=> 'The value of a.b is c.'

robojournalist('{which?a:{b}}', {which: true, b: 'y'});
//=> 'a'

robojournalist('{which?a:{b}}', {which: false, b: 'y'});
//=> 'y'

Braces can be nested to any depth.

Use {:} and {?} to add a colon and question mark to the output.

API

robojournalist(template, data)

template

Type: string

The template string, with braced variable names.

data

Type: object

If the template string refers to {varName}, the value of data.varName will be placed in the output.

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.3

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago