nochso / html-compress-twig

Twig extension for compressing HTML and inline CSS/JS using WyriHaximus/HtmlCompress
Other
81 stars 19 forks source link

compression escape + javascript - problem #10

Open spagu opened 6 years ago

spagu commented 6 years ago

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 ?

nochso commented 6 years ago

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.

madsem commented 6 years ago

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