Here is one solution to the problem using "if":

<template bind="{{node}}">
    <template if="{{type == 'fm'}}">
        <fm-view node="{{}}"></fm-view>
    </template>
    <template if="{{type == 'tab'}}">
        <tab-view node="{{}}"></tab-view>
    </template>
    <template if="{{type == 'xor'}}">
        <xor-view node="{{}}"></xor-view>
    </template>
    <template if="{{type == 'var'}}">
        <var-view node="{{}}"></var-view>
    </template>
</template>


And here is another using "template ref":

<template bind="{{node}}">
    <template id="fm"><fm-view node="{{}}"></fm-view></template>
    <template id="tab"><tab-view node="{{}}"></tab-view></template>
    <template id="xor"><xor-view node="{{}}"></xor-view></template>
    <template id="var"><var-view node="{{}}"></var-view></template>

    <template bind ref="{{type}}"></template>

</template>


Neither seems all that elegant however. Any other suggestions?


On Thursday, March 19, 2015 at 8:25:53 AM UTC-7, Dave Ford wrote:
>
> I saw an example in the docs using the ref attribute of template. I want 
> to do the same thing using custom elements.
>
> I know this syntax won't work but it should convey the general idea of 
> what I am trying to do:
>
> <{{node.nodeType }} node={{node}}>
>
> In my old GWT app I had a strategy function for this purpose:
>
> NodeRenderer r = determineNodeRenderer(node.nodeType )
> r.render(node)
>
> How would I achieve similar using polymer?
>
> Thanks
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/0b449ac3-c61b-4be6-ab32-f711e276bcd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to