Skip to content

Commit 45443b4

Browse files
mohd-akramjaylinski
authored andcommitted
Revert "Improve partial indenting performance"
This reverts commit 08fddee. The change caused performance regressions in some cases and performance was not consistent across engines.
1 parent 8841a5f commit 45443b4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/handlebars/runtime.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ export function template(templateSpec, env) {
8989
}
9090
if (result != null) {
9191
if (options.indent) {
92-
result =
93-
options.indent + result.replace(/\n(?!$)/g, '\n' + options.indent);
92+
let lines = result.split('\n');
93+
for (let i = 0, l = lines.length; i < l; i++) {
94+
if (!lines[i] && i + 1 === l) {
95+
break;
96+
}
97+
98+
lines[i] = options.indent + lines[i];
99+
}
100+
result = lines.join('\n');
94101
}
95102
return result;
96103
} else {

0 commit comments

Comments
 (0)