Fixed variable name being appended by space.
This commit is contained in:
parent
d23b5e3b8f
commit
66dae1820a
|
@ -37,14 +37,14 @@ export default function parseTemplate(template, data) {
|
||||||
// Syntax: {{ variableName }}
|
// Syntax: {{ variableName }}
|
||||||
// Does: Inserts a variable, if it exists.
|
// Does: Inserts a variable, if it exists.
|
||||||
.replace(
|
.replace(
|
||||||
/{{\s*(.+)\s*}}/gm,
|
/{{\s*(\S+?)\s*}}/gm,
|
||||||
(match, variableName) => {
|
(match, variableName) => {
|
||||||
if (flattenedData[variableName] === undefined || flattenedData[variableName] === null) {
|
if (flattenedData[variableName] === undefined || flattenedData[variableName] === null) {
|
||||||
error(`Error: ${variableName} is not defined!`)
|
error(`Error: "${variableName}" is not defined!`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
log(`${variableName} = ${flattenedData[variableName]}`)
|
log(`"${variableName}" = ${flattenedData[variableName]}`)
|
||||||
return flattenedData[variableName]
|
return flattenedData[variableName]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -54,14 +54,14 @@ export default function parseTemplate(template, data) {
|
||||||
// {% endif %}
|
// {% endif %}
|
||||||
// Does: includes <code to include> if variableName exists and is true.
|
// Does: includes <code to include> if variableName exists and is true.
|
||||||
.replace(
|
.replace(
|
||||||
/^{%\s*if\s*(.+)\s*%}$([\s\S]*?)^{%\s*endif\s*%}$/gm,
|
/^{%\s*if\s*(\S+?)\s*%}$([\s\S]*?)^{%\s*endif\s*%}$/gm,
|
||||||
(match, variableName, codeBlock) => {
|
(match, variableName, codeBlock) => {
|
||||||
if (flattenedData[variableName] === undefined || flattenedData[variableName] === null) {
|
if (flattenedData[variableName] === undefined || flattenedData[variableName] === null) {
|
||||||
error(`Error: ${variableName} is not defined!`)
|
error(`Error: "${variableName}" is not defined!`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
log(`${variableName} = ${flattenedData[variableName]}`)
|
log(`"${variableName}" = ${flattenedData[variableName]}`)
|
||||||
return flattenedData[variableName] ? codeBlock : ""
|
return flattenedData[variableName] ? codeBlock : ""
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user