choojs / hyperx

🏷 - tagged template string virtual dom builder
BSD 2-Clause "Simplified" License
1.01k stars 48 forks source link

Fix template parts inside comments #75

Closed goto-bus-stop closed 5 years ago

goto-bus-stop commented 5 years ago

Comment state is preserved when entering a template ${embed} part, so you can do things like

html`
  <div>
    <!-- ${someElementThatIWantHidden()} -->
    ${someElementThatIWantShown()}
  </div>
`

instead of the somewhat clumsy

html`
  <div>
    ${''/*
      someElementThatIWantHidden()
    */}
  </div>
`

Of course, in the first situation, someElementThatIWantHidden() is still evaluated, just not inserted.

With opts.comments = true, the embedded parts are stringified and concatenated.