Skip to content

Commit 53a5f13

Browse files
mohd-akramjaylinski
authored andcommitted
Improve partial indenting performance
1 parent cf5c0be commit 53a5f13

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

lib/handlebars/runtime.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,8 @@ export function template(templateSpec, env) {
9393
}
9494
if (result != null) {
9595
if (options.indent) {
96-
let lines = result.split('\n');
97-
for (let i = 0, l = lines.length; i < l; i++) {
98-
if (!lines[i] && i + 1 === l) {
99-
break;
100-
}
101-
102-
lines[i] = options.indent + lines[i];
103-
}
104-
result = lines.join('\n');
96+
result =
97+
options.indent + result.replace(/\n(?!$)/g, '\n' + options.indent);
10598
}
10699
return result;
107100
} else {

0 commit comments

Comments
 (0)