Closed szinya closed 11 years ago
.replace
is a very heavy operation that impact perfomance for a several times.
Simple benchmark:
Without .replace
:
Escaped : 2407ms
Unescaped : 162ms
Total : 2569ms
With .replace
:
Escaped : 5384ms
Unescaped : 3054ms
Total : 8438ms
And it not solving all indentation problems. You can see it with example.js.
I know that indentation in result html is not ideal, but it fast. In most cases result indentation does not matter. For other caces i reccomend to use external html beautifiers like this.
Taking the output formatting forward I made this:
into this:
It works by prefixing each line in every
include
's andcontent
's content with the original tag's indentation. This way one can author all the partials with 0 initial indentation and every command tag can be placed correctly in the document flow.