pyjade icon indicating copy to clipboard operation
pyjade copied to clipboard

Do not use comments in scripts.

Open karland opened this issue 10 years ago • 1 comments

pyjade does not deal with comments in scripts properly.

I had

script.
    $(document).ready(function() {
        // Comment
        $('#id').select2();
    });  

which was converted to

<script>$(document).ready(function() {    // Comment    $('#id').select2();});  
</script>

karland avatar Jan 16 '15 22:01 karland

It turns out that this is being caused by pyjade improperly handling .. From the test suite, if we use script over script., then whitespace is preserved.

@syrusakbary This is very confusing behavior as it varies from our expectations from the node.js Jade library.

https://github.com/syrusakbary/pyjade/blob/74e16e748eaf16957b6892476b49589787e23758/pyjade/testsuite/cases/script.whitespace.jade

https://github.com/syrusakbary/pyjade/blob/74e16e748eaf16957b6892476b49589787e23758/pyjade/testsuite/cases/script.whitespace.html

If we use that in the jade-lang.com example, it uses HTML behavior for script without a . because that is intended to help at defining browser-side templates:

script
  // Hello
  p what's up
<script>
  <!-- Hello-->
  <p>what's up</p>
</script>

vs with a .

script.
  // Hello
  p what's up
<script>
  // Hello
  p what's up
</script>

twolfson avatar Jun 14 '15 22:06 twolfson