voku / HtmlMin

:clamp: HtmlMin: HTML Compressor and Minifier via PHP
MIT License
161 stars 22 forks source link

Bad minify text/x-custom-template #38

Closed hryvinskyi closed 5 years ago

hryvinskyi commented 5 years ago
$html = "
            <!doctype html>
            <html lang=\"nl\">
                <head>
                </head>
              <body>
              <div class=\"price-box price-tier_price\" data-role=\"priceBox\" data-product-id=\"1563\" data-price-box=\"product-id-1563\">

                </div>
                <script type=\"text/x-custom-template\" id=\"tier-prices-template\">
                <ul class=\"prices-tier items\">
                    <% _.each(tierPrices, function(item, key) { %>
                    <%  var priceStr = '<span class=\"price-container price-tier_price\">'
                            + '<span data-price-amount=\"' + priceUtils.formatPrice(item.price, currencyFormat) + '\"'
                            + ' data-price-type=\"\"' + ' class=\"price-wrapper \">'
                            + '<span class=\"price\">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>'
                            + '</span>'
                        + '</span>'; %>
                    <li class=\"item\">
                        <%= 'some text %1 %2'.replace('%1', item.qty).replace('%2', priceStr) %>
                        <strong class=\"benefit\">
                           save <span class=\"percent tier-<%= key %>\">&nbsp;<%= item.percentage %></span>%
                        </strong>
                    </li>
                    <% }); %>
                </ul>
            </script>
            <div data-role=\"tier-price-block\"></div>
              </body>
            </html>
            ";

        echo $this->htmlMin->minify($html);

        <!DOCTYPE html><html lang=nl><head> <body><div class="price-box price-tier_price" data-price-box=product-id-1563 data-product-id=1563 data-role=priceBox></div> <script id=tier-prices-template type=text/x-magento-template><ul class="items prices-tier"><____simple_html_dom__voku__percent____ _.each="" ____simple_html_dom__voku__percent____="" function="" key=""><____simple_html_dom__voku__percent____ ____simple_html_dom__voku__plus____="" class=price-wrapper data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '" data-price-type="" pricestr='<span class="price-container price-tier_price">' var="">' + '<span class=price>' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>' + '' + ''; %> <li class=item><____simple_html_dom__voku__percent____ ____simple_html_dom__voku__percent____="" ____simple_html_dom__voku__percent____1="" ____simple_html_dom__voku__percent____2="" item.qty="" pricestr="" text=""><strong class=benefit> save <span class="%> key percent tier-<%=">&nbsp;<____simple_html_dom__voku__percent____ ____simple_html_dom__voku__percent____="" item.percentage=""></____simple_html_dom__voku__percent____></span>% </strong> </____simple_html_dom__voku__percent____></li> <____simple_html_dom__voku__percent____ ____simple_html_dom__voku__percent____=""></____simple_html_dom__voku__percent____></____simple_html_dom__voku__percent____></____simple_html_dom__voku__percent____></ul> </script><div data-role=tier-price-block></div>
voku commented 5 years ago

Thanks for the bug report. It's fixed in version 4.0.1.

Happy coding!