Passing renderer to the marko templates to render inner components

35 views
Skip to first unread message

suraj silicon

unread,
Jan 29, 2015, 4:08:41 PM1/29/15
to rapt...@googlegroups.com

I am creating a grid (table) component which may have different components within each cell. 

I want to know if it’s possible to make it more generic, where user can pass any component and get it rendered in grid cell.

 

One way is check for some flag within grid component and call the corresponding component based on that. 

I want a more generic one, where user will be able to pass a renderer for the cell and get any component rendered.


Could you please let me know if it's possible

Patrick Steele-Idem

unread,
Jan 29, 2015, 4:14:41 PM1/29/15
to rapt...@googlegroups.com
Marko definitely allows what you are describing. Every UI component should have a renderer that can be invoked to produce the output HTML given some input. You can easily pass in a component’s renderer to the Marko template and within the template you can easily invoke any renderer function (I.e. function(input, out)) using code similar to the following:

<invoke function=“item.actionsRenderer(item, out)”/>

When the renderer is invoked it will write out its output to the provided output stream.

Hopefully that solves your problem, but let me know if not.

Thanks,
Patrick
Reply all
Reply to author
Forward
0 new messages