davidjamesstone / superviews.js

Template engine targeting incremental-dom
http://davidjamesstone.github.io/superviews.js/playground/
246 stars 15 forks source link

Include templates inside other templates #43

Closed rogi29 closed 6 years ago

rogi29 commented 6 years ago

I find it an issue, where I want to include multiple templates inside a parent template using an HTML like syntax to create modular components.

Is there a possibility to extend the handler function (the one on line 139), therefore allowing us to create custom tags like <include> or <component> that would be compiled to js functions? For example:

<template name="todoComponent" args="attrs innerHTML state">
  <span data-type="{attrs.type}" data-done="{state.done}">{innerHTML}</span>
</template>

<template name="todoListComponent" >
  <component name="todoComponent" type="work">Fix Bug01</component>
  <component name="todoComponent" type="work">Fix Bug02</component>
</template>
rogi29 commented 6 years ago

I have already found a solution.

alexsad commented 6 years ago
<template>
    <require from="./module-a"/>
    <div>
      <module-a title="new title!"/>
    </div>
</template>

from https://ferrugemjs.github.io/home-page/documentation.html

rogi29 commented 6 years ago

This is ferrugem, I wanted it purely with superviews.js. Thank you anyways, I already found a solution, and it is rewriting the code to allow custom directives, custom tags and even custom mods. I might release a repository soon with credit to the original of course.