mattelen / vue3-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
47 stars 12 forks source link

Add slots support #9

Open yariksav opened 2 years ago

yariksav commented 2 years ago

Hi, @mattelen ! Thnak you for component and your work!

Just one feature request - to add slots support at row https://github.com/mattelen/vue3-runtime-template/blob/4f20a4c4ebbccbbfefadcfe7edb6b757b093aa09/index.js#L115

change to

return h(dynamic, {...finalProps}, this.$slots);

Motivation

Than we can use component like

    <VRuntimeTemplate
      :template="template"
    >
      Some slot data
      <div slot="named">Some named slot data</div>
    </VRuntimeTemplate>

where the template is like

<div>
    Some template data
    <slot />
    <slot name="named" />
</div>

Result will be

 <div>
    Some template data
    Some slot data
    <div>Some named slot data</div>
</div>