Skip to content

Commit 7711830

Browse files
authored
perf: pulled definitions of ignore from iteration
1 parent 994e196 commit 7711830

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const revertBackupedLocals = require('./backup').revert
1010
const placeholders = require('./placeholders')
1111

1212
const delimitersSettings = []
13-
let conditionals, switches, loops, scopes, ignored
13+
let conditionals, switches, loops, scopes, ignored, ignoredBefore, ignoredAfter, toReplace, ignoredNodeExpression, ignoredAttrsExpression
1414

1515
/**
1616
* @description Creates a set of local variables within the loop, and evaluates all nodes within the loop, returning their contents
@@ -147,6 +147,13 @@ module.exports = function postHTMLExpressions (options) {
147147
delimitersSettings[0] = delimiters[1]
148148
delimitersSettings[1] = delimiters[0]
149149
}
150+
151+
152+
ignoredBefore = delimitersSettings[1].text[0]
153+
ignoredAfter = delimitersSettings[1].text[1]
154+
toReplace = new RegExp(`@${ignoredBefore}`, 'g')
155+
ignoredNodeExpression = new RegExp(`@${ignoredBefore}(.+?)${ignoredAfter}`, 'g')
156+
ignoredAttrsExpression = new RegExp(`.*@${ignoredBefore}(.+?)${ignoredAfter}`)
150157

151158
// kick off the parsing
152159
return walk.bind(null, { locals: options.locals })
@@ -174,12 +181,6 @@ function walk (opts, nodes) {
174181
return m
175182
}
176183

177-
const ignoredBefore = delimitersSettings[1].text[0]
178-
const ignoredAfter = delimitersSettings[1].text[1]
179-
const toReplace = new RegExp(`@${ignoredBefore}`, 'g')
180-
const ignoredNodeExpression = new RegExp(`@${ignoredBefore}(.+?)${ignoredAfter}`, 'g')
181-
const ignoredAttrsExpression = new RegExp(`.*@${ignoredBefore}(.+?)${ignoredAfter}`)
182-
183184
// if we have a string, match and replace it
184185
if (typeof node === 'string') {
185186
// if node contains ignored expression delimiter, output as-is

0 commit comments

Comments
 (0)