README
Roll your own Mustache-like plaintext template language with custom syntax.
var parse = require('plaintemplate-parse')
var assert = require('assert')
assert.deepEqual(
parse(
// Template input
'(( five { ))Howdy, (( = name ))! (( } ))',
// Use custom double-parentheses template tags.
{ open: '((', close: '))', start: '{', end: '}' }),
[ { tag: 'five',
position: { line: 1, column: 1 },
content: [
{ text: 'Howdy, ',
position: { line: 1, column: 13 } },
{ tag: '= name',
position: { line: 1, column: 20 } },
{ text: '! ',
position: { line: 1, column: 32 } } ] } ])
The package exports a single function returning arrays of token objects for text and template tag tokens, of two arguments:
- Input, a string, containing the template text to parse
- Delimiters, an object with the following keys specifying the syntax for template tags:
open
,"<%"
by defaultclose
,"%>"
by defaultstart
,"{"
by defaultend
,"}"
by default