@@ -1712,7 +1712,44 @@ function view_parse(content, minify, filename) {
17121712 if ( minify )
17131713 content = removeComments ( content ) ;
17141714
1715- content = compressCSS ( compressJS ( content , 0 , filename ) , 0 , filename ) ;
1715+ var nocompressHTML = false ;
1716+ var nocompressJS = false ;
1717+ var nocompressCSS = false ;
1718+
1719+ content = content . replace ( / @ \{ n o c o m p r e s s \s \w + } / gi, function ( text ) {
1720+
1721+ var index = text . lastIndexOf ( ' ' ) ;
1722+ if ( index === - 1 )
1723+ return '' ;
1724+
1725+ switch ( text . substring ( index , text . length - 1 ) . trim ( ) ) {
1726+ case 'all' :
1727+ nocompressHTML = true ;
1728+ nocompressJS = true ;
1729+ nocompressCSS = true ;
1730+ break ;
1731+ case 'html' :
1732+ nocompressHTML = true ;
1733+ break ;
1734+ case 'js' :
1735+ case 'script' :
1736+ case 'javascript' :
1737+ nocompressJS = true ;
1738+ break ;
1739+ case 'css' :
1740+ case 'style' :
1741+ nocompressCSS = true ;
1742+ break ;
1743+ }
1744+
1745+ return '' ;
1746+ } ) . trim ( ) ;
1747+
1748+ if ( ! nocompressJS )
1749+ content = compressJS ( content , 0 , filename ) ;
1750+ if ( ! nocompressCSS )
1751+ content = compressCSS ( content , 0 , filename ) ;
1752+
17161753 content = framework . _version_prepare ( content ) ;
17171754
17181755 var DELIMITER = '\'' ;
@@ -1722,22 +1759,29 @@ function view_parse(content, minify, filename) {
17221759 var builder = 'var $EMPTY=\'\';var $length=0;var $source=null;var $tmp=index;var $output=$EMPTY' ;
17231760 var command = view_find_command ( content , 0 ) ;
17241761 var compressed = '' ;
1762+ var nocompress = false ;
1763+ var isFirst = false ;
17251764
17261765 function escaper ( value ) {
17271766
17281767 var is = value . match ( / [ ^ \> ] \n \s { 1 , } $ / ) ;
1729- value = compressHTML ( value , minify ) ;
1768+
1769+ if ( ! nocompressHTML )
1770+ value = compressHTML ( value , minify ) ;
1771+ else if ( ! isFirst ) {
1772+ isFirst = true ;
1773+ value = value . replace ( / ^ \s + / , '' ) ;
1774+ }
17301775
17311776 if ( value === '' )
17321777 return '$EMPTY' ;
17331778
1734- if ( value [ 0 ] === ' ' && value [ 1 ] === '<' )
1779+ if ( ! nocompressHTML && value [ 0 ] === ' ' && value [ 1 ] === '<' )
17351780 value = value . substring ( 1 ) ;
17361781
1737- if ( is )
1782+ if ( ! nocompressHTML && is )
17381783 value += ' ' ;
17391784
1740- // if (value.match(/\n|\t|\r|\'|\\/) !== null)
17411785 if ( value . match ( / \n | \r | \' | \\ / ) !== null )
17421786 return DELIMITER_UNESCAPE + escape ( value ) + DELIMITER_UNESCAPE_END ;
17431787
@@ -1858,7 +1902,11 @@ function view_parse(content, minify, filename) {
18581902 } else if ( cmd === 'endif' || cmd === 'fi' ) {
18591903 builder += '}$output+=$EMPTY' ;
18601904 } else {
1861- tmp = view_prepare ( command . command , newCommand , functionsName ) ;
1905+
1906+ tmp = view_prepare ( command . command , newCommand , functionsName , function ( ) {
1907+ nocompress = true ;
1908+ } ) ;
1909+
18621910 if ( tmp ) {
18631911 if ( view_parse_plus ( builder ) )
18641912 builder += '+' ;
@@ -1921,6 +1969,7 @@ function view_prepare(command, dynamicCommand, functions) {
19211969 return '$STRING(' + command . substring ( 1 ) + ')' ;
19221970
19231971 switch ( name ) {
1972+
19241973 case 'foreach' :
19251974 case 'end' :
19261975 return '' ;
0 commit comments