robojournalist

0.0.9 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i robojournalist

    Weekly Downloads

    1

    Version

    0.0.9

    License

    MIT

    Unpacked Size

    7.22 kB

    Total Files

    4

    Last publish

    Collaborators

    • jtrim-ons