pla

plating

Simple JS Templating

Showing:

Popularity

Downloads/wk

3

GitHub Stars

0

Maintenance

Last Commit

2yrs ago

Contributors

1

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

plating

Build Status Coverage Status Known Vulnerabilities npm

Simple JS Templating

Installation

npm install --save plating

Usage

Provide any string with all placeholders defined as {{placeholder|default value}}, or simply as {{placeholder}}.

If no value for placeholder is defined, it will fall back to the default value, if provided. If no value is defined and there is no default value, the placeholder will be displayed as entered. In this case, {{placeholder}} would be visible in the rendered version.

Example

const plating = require('plating');

let template = '{{app}} is a simple template system for {{lang|JS}}';

// Get tokens to find out what can be substituted
let tokens = plating.extract(template);

// Render the template, notice the default value used with `lang`
let rendered = plating.render(template, {
    app: 'plating'
});

In the example above, tokens contains:

[
  {
    raw: '{{app}}',
    key: 'app',
    defaultValue: undefined
  },
  {
    raw: '{{lang|JS}}',
    key: 'lang',
    defaultValue: 'JS'
  }
]

And rendered is:

plating is a simple template system for JS

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial