Issues

Issue #8 resolved

[PATCH] Enable Buffet plugin loading of string templates

Anonymous created an issue

The following patch adds support to the TG Buffet plugin for loading templates from a string. This allows Mako to be used in [http://toscawidgets.org ToscaWidgets]

Comments (4)

  1. alberto

    Just a FYI, a Tosca widget written in mako looks like:

    1. !py from toscawidgets.api import Widget

    class MakoWidget(Widget): params = ["rows"] rows = [] engine_name = "mako" template = """ <table id="${id}> % for row in rows: ${makerow(row)} % endfor </table>

    <%def name="makerow(row)"> <tr> % for name in row: <td>${name}</td> % endfor </tr> </%def> """

    def update_params(self,d): super(MakoWidget, self).update_params(d) if d['value']: d['rows'] = d['value']

    if name == 'main': w = MakoWidget("mako") print w.render([('foo', 'bar')]*5)

    (needs attached patch to Mako to work)

    Alberto

  2. Mike Bayer repo owner

    just a note, based on the convo in [ticket:10] the template code should look like:

    <%page args="id=''"/> <table id="${id}> % for row in rows: ${makerow(row)} % endfor </table>

    <%def name="makerow(row)"> <tr> % for name in row: <td>${name}</td> % endfor </tr> </%def>

  3. Log in to comment