Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Enable Buffet plugin loading of string templates #8

Closed
sqlalchemy-bot opened this issue Jan 11, 2007 · 6 comments
Closed

[PATCH] Enable Buffet plugin loading of string templates #8

sqlalchemy-bot opened this issue Jan 11, 2007 · 6 comments

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Anonymous

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]


Attachments: template_string.2.patch | template_string.patch

@sqlalchemy-bot
Copy link
Author

Alberto Rodríguez (@alberto) wrote:

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

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

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

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>

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

reassigning to ben so that he can insure the patch works (i dont have a pylons/TG setup here to test with)

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed assignee from "zzzzeek" to "bbangert"

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

patch looks good so i committed in [changeset:185]

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant