BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

jsrender missing whitespace in rendered output when template expression immediately follows opening table element #415

Closed johan-ohrn closed 5 years ago

johan-ohrn commented 5 years ago

Look at this fiddle with the console open and inspect the generated html code. This output from this template is missing a whitespace between tag and the attribute:

<table {{if 1}} data-whatever{{/if}}>
</table>

it's rendered as:

<tabledata-whatever>
</tabledata-whatever>

Expected rendered output is:

<table data-whatever>
</table>

Even manually adding whitespsace inside the if-expression doesn't help. I'm only having this issue with the table tag. Divs and other elements seem to work as expected.

BorisMoore commented 5 years ago

Another excellent catch. Thank you!

Here is a proposed fix. It is a one-liner in jsviews.js or jquery.views.js download.zip

if (elCnt && !inTag) {
    // elContent maps tagNames which have only element content...

Let me know if it works correctly for you.

johan-ohrn commented 5 years ago

I can confirm that it works. Thanks a lot!

BorisMoore commented 5 years ago

The fix is included in the new v1.0.3 release.