WebReflection / uhtml

A micro HTML/SVG render

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue rendering dynamic comments

keul opened this issue · comments

(probably follows discussion on #41)

Although I'm applying your suggestion about filtering instead of trying to return nullish stuff, sometimes I ended up applying the html`<!-- something -->` approach as, in some cases, it's easy for me to use the ternary operator.

I just noticed that I can't use a dynamic value inside the comment. This fails:

const comment = 'here we are'

html`${html`<!-- ${comment} -->`}

This is the error:

bad template: <!-- <!--isµ0--> -->

Example: https://codesandbox.io/s/admiring-cori-tzc6h?file=/src/index.js

Not a real issue for me, it was more a debugging code, but I'm wondering if this is an issue. 👋

this a funny one ... and I believe not supported by any of my libraries ... can I ask you what's the use case for that?

I just wanted to display which "empty element" was in the tree… just debugging purpose (already removed from my code)

P.S. work around, if needed:

html([`<!-- ${whatever} -->`])

but never ever had the need to use dynamic comments within these libraries

I'm afraid this complicates the critical parsing path so, if it's for debugging only, I might put the ugly workaround somewhere in the F.A.Q. or documentation, but as I think there are no real world use cases, but a workaround in case there is a debugging need, I hope that's fine.