html-compress-twig icon indicating copy to clipboard operation
html-compress-twig copied to clipboard

compression escape + javascript - problem

Open spagu opened this issue 6 years ago • 2 comments

I have a javascript added to the template and function is doing wrong minification:

$('#auto').append('<tr id="auto_'+data.auto_id+'}}"><td>'+data.auto_movie+'</td><td><div class="form-check checkbox-slider--a checkbox-slider-md"><label>....

basically it sees it as HTML.

I tried to escape compression but I am getting error 'endhtmlcompress' is not found when inside template I put it twice.

start file here

{% htmlcompress %}
(include) HTML to be compressed
{% endhtmlcompress %}
(include) HTML NOT TO BE COMPRESSED
{% htmlcompress %}
(include) REST OF HTML TO BE COMPRESSED
{% endhtmlcompress %}

Any Idea how to work it out ?

spagu avatar Jul 05 '18 18:07 spagu

wrong minification

This package is only a Twig extension, the actual compression is done by WyriHaximus/HtmlCompress and the packages it uses.

I tried to escape compression but I am getting error 'endhtmlcompress' is not found when inside template I put it twice.

I can't reproduce it. Consecutive {% htmlcompress %} tags work fine. Are you nesting the htmlcompress tags in the includes maybe? I haven't tested that.

nochso avatar Jul 05 '18 19:07 nochso

Make sure your script tag includes type="text/javascript" Just adding this fixed the issues I was seeing.

madsem avatar Sep 23 '18 09:09 madsem