MCPcopy Create free account
hub / github.com/totaljs/framework / compressView

Function compressView

internal.js:2548–2581  ·  view source on GitHub ↗
(html, minify)

Source from the content-addressed store, hash-verified

2546}
2547
2548function compressView(html, minify) {
2549
2550 var cache = [];
2551 var beg = 0;
2552 var end;
2553
2554 while (true) {
2555 beg = html.indexOf('@{compile ', beg - 1);
2556 if (beg === -1)
2557 break;
2558 end = html.indexOf('@{end}', beg + 6);
2559 if (end === -1)
2560 break;
2561 cache.push(html.substring(beg, end + 6));
2562 html = html.substring(0, beg) + '#@' + (cache.length - 1) + '#' + html.substring(end + 6);
2563 }
2564
2565 while (true) {
2566 beg = html.indexOf('@{', beg);
2567 if (beg === -1)
2568 break;
2569 end = html.indexOf('}', beg + 2);
2570 if (end === -1)
2571 break;
2572 cache.push(html.substring(beg, end + 1));
2573 html = html.substring(0, beg) + '#@' + (cache.length - 1) + '#' + html.substring(end + 1);
2574 }
2575
2576 html = compressHTML(html, minify, false);
2577
2578 return html.replace(/#@\d+#/g, function(text) {
2579 return cache[+text.substring(2, text.length - 1)];
2580 });
2581}
2582
2583/**
2584 * Inline JS compressor

Callers 1

view_parseFunction · 0.85

Calls 1

compressHTMLFunction · 0.85

Tested by

no test coverage detected