object-placeholder
Version:
It's a zero-dependency package that exports default function: ```text placeholder(<template>, <data>, <options>) ``` and function with named params: ```text placeholder.replace({ template, data, options }) ``` where: - `template` - some template ( [string
48 lines (44 loc) • 828 B
JavaScript
const test = require('ava')
const { caseObjectPlaceholder } = require('./placeholders.case')
test('placeholder.stringify: false',
caseObjectPlaceholder,
{
template: '{{list}}',
options: {
stringify: false,
},
data: {
list: [1, 2, 3],
}
},
'1,2,3',
)
test('placeholder.stringify: true',
caseObjectPlaceholder,
{
template: '{{list}}',
options: {
stringify: true,
},
data: {
list: [1, 2, 3],
}
},
'[1,2,3]',
)
test('placeholder.stringify: function',
caseObjectPlaceholder,
{
template: '{{list}}',
options: {
stringify: value =>
(Array.isArray(value))
? value.join(' ')
: value.toString(),
},
data: {
list: [1, 2, 3],
}
},
'1 2 3',
)