Skip to content

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

@lowlighter

Description

@lowlighter

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: mustachespecSpec definition for non-well defined behaviors

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions