@@ -774,6 +774,64 @@ public function testHtmlInsideJavaScriptTemplates()
774
774
static ::assertSame ($ expected , $ htmlMin ->minify ($ html ));
775
775
}
776
776
777
+ public function testOverwriteSpecialScriptTags ()
778
+ {
779
+ $ html = "<!doctype html>
780
+ <html lang= \"nl \">
781
+ <head>
782
+ </head>
783
+ <body>
784
+ <script type= \"text/x-custom \">
785
+ <ul class= \"prices-tier items \">
786
+ <% _.each(tierPrices, function(item, key) { %>
787
+ <% var priceStr = '<span class= \"price-container price-tier_price \">'
788
+ + '<span data-price-amount= \"' + priceUtils.formatPrice(item.price, currencyFormat) + ' \"'
789
+ + ' data-price-type= \"\"' + ' class= \"price-wrapper \">'
790
+ + '<span class= \"price \">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>'
791
+ + '</span>'
792
+ + '</span>'; %>
793
+ <li class= \"item \">
794
+ <%= 'some text %1 %2'.replace('%1', item.qty).replace('%2', priceStr) %>
795
+ <strong class= \"benefit \">
796
+ save <span class= \"percent tier-<%= key %> \"> <%= item.percentage %></span>%
797
+ </strong>
798
+ </li>
799
+ <% }); %>
800
+ </ul>
801
+ </script>
802
+ <div data-role= \"tier-price-block \">
803
+ <div> Some Content </div>
804
+ </div>
805
+ </body>
806
+ </html> " ;
807
+
808
+ $ htmlMin = new voku \helper \HtmlMin ();
809
+ $ htmlMin ->overwriteSpecialScriptTags (['text/x-custom ' ]);
810
+ $ expected = <<<HTML
811
+ <!DOCTYPE html><html lang=nl><head> <body><script type=text/x-custom>
812
+ <ul class="prices-tier items">
813
+ <% _.each(tierPrices, function(item, key) { %>
814
+ <% var priceStr = '<span class="price-container price-tier_price">'
815
+ + '<span data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '"'
816
+ + ' data-price-type=""' + ' class="price-wrapper ">'
817
+ + '<span class="price">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>'
818
+ + '</span>'
819
+ + '</span>'; %>
820
+ <li class="item">
821
+ <%= 'some text %1 %2'.replace('%1', item.qty).replace('%2', priceStr) %>
822
+ <strong class="benefit">
823
+ save <span class="percent tier-<%= key %>"> <%= item.percentage %></span>%
824
+ </strong>
825
+ </li>
826
+ <% }); %>
827
+ </ul>
828
+ </script> <div data-role=tier-price-block><div> Some Content </div> </div>
829
+ HTML ;
830
+
831
+
832
+ static ::assertSame ($ expected , $ htmlMin ->minify ($ html ));
833
+ }
834
+
777
835
public function testHtmlClosingTagInSpecialScript ()
778
836
{
779
837
$ htmlMin = new \voku \helper \HtmlMin ();
0 commit comments