diff --git a/lib/index.js b/lib/index.js index 6074742..03f5c5d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,7 +10,7 @@ const revertBackupedLocals = require('./backup').revert const placeholders = require('./placeholders') const delimitersSettings = [] -let conditionals, switches, loops, scopes, ignored +let conditionals, switches, loops, scopes, ignored, delimitersReplace, unescapeDelimitersReplace /** * @description Creates a set of local variables within the loop, and evaluates all nodes within the loop, returning their contents @@ -124,12 +124,12 @@ module.exports = function postHTMLExpressions (options) { let before = escapeRegexpString(options.delimiters[0]) let after = escapeRegexpString(options.delimiters[1]) - const delimitersRegexp = new RegExp(`${before}(.+?)${after}`, 'g') + const delimitersRegexp = new RegExp(`(? - And here's a {{ variable }} that would be undefined. +
+ Here's one {{ variable }} and here's {{ another }}. And some bar.
diff --git a/test/fixtures/expression_ignored.html b/test/fixtures/expression_ignored.html index 5ce0b1d..e2795a8 100644 --- a/test/fixtures/expression_ignored.html +++ b/test/fixtures/expression_ignored.html @@ -1,4 +1,4 @@ @{{ foo }} -- And here's a @{{ variable }} that would be undefined. +
+ Here's one @{{ variable }} and here's @{{ another }}. And some {{ foo }}.
diff --git a/test/test-conditionals.js b/test/test-conditionals.js index c16b871..ac6c4c4 100644 --- a/test/test-conditionals.js +++ b/test/test-conditionals.js @@ -23,7 +23,7 @@ function process (t, name, options, log = false) { return clean(result.html) }) .then((html) => { - t.truthy(html === expect(name).trim()) + t.is(html, expect(name).trim()) }) } @@ -51,13 +51,13 @@ test('Conditionals - no render', (t) => { test('Conditionals - "if" tag missing condition', (t) => { return error('conditional_if_error', (err) => { - t.truthy(err.toString() === 'Error: the "if" tag must have a "condition" attribute') + t.is(err.toString(), 'Error: the "if" tag must have a "condition" attribute') }) }) test('Conditionals - "elseif" tag missing condition', (t) => { return error('conditional_elseif_error', (err) => { - t.truthy(err.toString() === 'Error: the "elseif" tag must have a "condition" attribute') + t.is(err.toString(), 'Error: the "elseif" tag must have a "condition" attribute') }) }) diff --git a/test/test-core.js b/test/test-core.js index 09bba9e..57dd597 100644 --- a/test/test-core.js +++ b/test/test-core.js @@ -23,7 +23,7 @@ function process (t, name, options, log = false) { return clean(result.html) }) .then((html) => { - t.truthy(html === expect(name).trim()) + t.is(html, expect(name).trim()) }) } diff --git a/test/test-scopes.js b/test/test-scopes.js index 1e14364..6923386 100644 --- a/test/test-scopes.js +++ b/test/test-scopes.js @@ -23,7 +23,7 @@ function process (t, name, options, log = false) { return clean(result.html) }) .then((html) => { - t.truthy(html === expect(name).trim()) + t.is(html, expect(name).trim()) }) } diff --git a/test/test-switch.js b/test/test-switch.js index 1b63abe..9d83c0a 100644 --- a/test/test-switch.js +++ b/test/test-switch.js @@ -23,7 +23,7 @@ function process (t, name, options, log = false) { return clean(result.html) }) .then((html) => { - t.truthy(html === expect(name).trim()) + t.is(html, expect(name).trim()) }) } @@ -75,7 +75,7 @@ test('Switch - dynamic expression', (t) => { test('Switch - no switch attribute', (t) => { return error('switch_no_attr', (err) => { - t.truthy(err.toString() === 'Error: the "switch" tag must have a "expression" attribute') + t.is(err.toString(), 'Error: the "switch" tag must have a "expression" attribute') }) })