(html, minify, isChunk)
| 2908 | } |
| 2909 | |
| 2910 | function compressHTML(html, minify, isChunk) { |
| 2911 | |
| 2912 | if (!html || !minify) |
| 2913 | return html; |
| 2914 | |
| 2915 | html = removeComments(html.replace(REG_WIN, '')); |
| 2916 | |
| 2917 | var tags = ['script', 'textarea', 'pre', 'code']; |
| 2918 | var id = '[' + new Date().getTime() + ']#'; |
| 2919 | var cache = {}; |
| 2920 | var indexer = 0; |
| 2921 | var length = tags.length; |
| 2922 | var chars = 65; |
| 2923 | var tagBeg, tagEnd, beg, end, len, key, value; |
| 2924 | |
| 2925 | for (var i = 0; i < length; i++) { |
| 2926 | var o = tags[i]; |
| 2927 | |
| 2928 | tagBeg = '<' + o; |
| 2929 | tagEnd = '</' + o; |
| 2930 | |
| 2931 | beg = html.indexOf(tagBeg); |
| 2932 | end = 0; |
| 2933 | len = tagEnd.length; |
| 2934 | |
| 2935 | while (beg !== -1) { |
| 2936 | |
| 2937 | end = html.indexOf(tagEnd, beg + 3); |
| 2938 | if (end === -1) { |
| 2939 | if (isChunk) |
| 2940 | end = html.length; |
| 2941 | else |
| 2942 | break; |
| 2943 | } |
| 2944 | |
| 2945 | key = id + (indexer++) + String.fromCharCode(chars++); |
| 2946 | if (chars > 90) |
| 2947 | chars = 65; |
| 2948 | |
| 2949 | value = html.substring(beg, end + len); |
| 2950 | |
| 2951 | if (!i) { |
| 2952 | end = value.indexOf('>'); |
| 2953 | len = value.indexOf('type="text/template"'); |
| 2954 | |
| 2955 | if (len < end && len !== -1) { |
| 2956 | beg = html.indexOf(tagBeg, beg + tagBeg.length); |
| 2957 | continue; |
| 2958 | } |
| 2959 | |
| 2960 | len = value.indexOf('type="text/html"'); |
| 2961 | |
| 2962 | if (len < end && len !== -1) { |
| 2963 | beg = html.indexOf(tagBeg, beg + tagBeg.length); |
| 2964 | continue; |
| 2965 | } |
| 2966 | |
| 2967 | len = value.indexOf('type="text/ng-template"'); |
no test coverage detected