marko-js-archive / marko-widgets

[LEGACY] Module to support binding of behavior to rendered UI components rendered on the server or client
http://v3.markojs.com/docs/marko-widgets/
MIT License
142 stars 40 forks source link

bundling internal references without calling explicitly #130

Open yomed opened 8 years ago

yomed commented 8 years ago

In my running use-case of using a dynamic-tag to dynamically include subcomponents of type template/renderer/widget, I've run into a new problem. I assume resources are client aggregated for widgets based on walking through references.

Such as:

<div w-bind>
    <subcomponent />
</div>

But my code actually looks like:

<div w-bind>
    <dynamic-tag module="subcomponent" />
</div>

In this second case, is there some way for me to make sure that the compiled subcomponent is included in the client bundles? I need it's template.marko.js and renderer.js so that I could potentially rerender it's parent on the client.

I could use w-preserve to prevent rerendering in these cases, but given that the tags are dynamic, it's a bit harder to tell which ones should be preserved (unless there would be a way to put w-preserve on a non-widget).

yomed commented 8 years ago

The dynamic-tag has some logic to process tag data, and a template that looks like this:

<if test="data.type === 'renderer' || data.type === 'widgetWithoutId'">
    <invoke function="data.renderer(data.model, out)" />
</if>
<else-if test="data.type === 'template'">
    <include template="${data.template}" entry="$data.model" />
</else-if>
<else-if test="data.type === 'widgetWithId'">
    <include template="./widget.marko" renderer="${data.renderer}" model="${data.model}" />
</else-if>