Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of triple mustache ({{{ and }}}) for raw html interpolation #36

Open
lowlighter opened this issue Oct 26, 2024 · 0 comments
Open
Labels
scope: mustache spec Spec definition for non-well defined behaviors
Milestone

Comments

@lowlighter
Copy link
Owner

lowlighter commented Oct 26, 2024

Scope

mustache

What do you want to define?

While the implemented parser is able to parse triple mustaches with the intention of injecting raw html, its "support" is not routed into the directive for the following reasons:

  • It's not that trivial to inject raw html in this case:
    • The Text node must be splitted in order to inject the html in-between
    • Injected html must be somewhat marked as "virtual" because they're not part of the document the user provided
      • It could probably be solved using the directive cache with a WeakMap<Text, WeakSet<HTMLElement>> mapping
  • It's not clear whether injected html should then be processed by the mizu renderer
    • Usually mustache engines prevent re-interpolation, so if the rendered html contains a nested mustache directive, technically it could be seen as re-interpolation
    • Should reactivity also applies to interpolated html in this case ?
      • It could cause some issues in rendering since these interpolated elements may become orphan by the time the mustache directive is rendered again. I don't think it'd cause too much issue, probably just wasted computing time (though iirc element without an ownerDocument are now skipped by reactive renders)
  • The *html directive can be used as a workaround, so this leave time for this to be discussed and thought about
    • Documentation has been patched to inform users about this behavior
<template *mustache>
   Hello {{{  `<i>foo</i>` }}} bar
</template>

I have searched for existing issues

Yes

@lowlighter lowlighter added this to the future milestone Oct 26, 2024
@lowlighter lowlighter added proposal spec Spec definition for non-well defined behaviors and removed proposal labels Oct 29, 2024
@lowlighter lowlighter changed the title mustache: handling of triple mustache ({{{ and }}}) Handling of triple mustache ({{{ and }}}) for raw html interpolation Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: mustache spec Spec definition for non-well defined behaviors
Projects
None yet
Development

No branches or pull requests

1 participant