STAN templates for widget ???

0 views
Skip to first unread message

Michael Schneider

unread,
Jan 1, 2006, 12:17:46 PM1/1/06
to TurboGears
Happy New year to all.


Before we went to church this morning I saw that STAN was now an option
for
turbogears templating.

Thanks to Kevin for creating the plug-in framework , and to Cliff for
implementing
the STAN plug-in.


Quick question before I dig in.


I like laying out my page with kid templates. This layout is more of a
designer
activity.


I have some very complex widgets that I would like to at least
prototype with
STAN.


Can the current system allow kid templates for the main page, and STAN
templates
in the widgets?


It seems like it should not be hard to do:


KID template
Widget.render renders XHTML fragment in place
....

This seems like a great use for a modular template system, and would
allow
reuse.

Can this work? This would be great.

Thanks
Mike

Michael Schneider

unread,
Jan 2, 2006, 11:52:04 AM1/2/06
to TurboGears
ping, (just to wake it up)

Kevin Dangoor

unread,
Jan 3, 2006, 10:23:39 AM1/3/06
to turbo...@googlegroups.com
On 1/1/06, Michael Schneider <michaels...@fuse.net> wrote:
> Can the current system allow kid templates for the main page, and STAN
> templates
> in the widgets?
>
>
> It seems like it should not be hard to do:
>
>
> KID template
> Widget.render renders XHTML fragment in place
> ....
>
> This seems like a great use for a modular template system, and would
> allow
> reuse.
>
> Can this work? This would be great.

This was not a use case that I tested for, so it may or may not work.
My guess is that it would work.

class MyWidget(Widget):
template="stan:foo.bar.baz"

should do it. But, that's entirely untested and not something I plan
to spend time on.

Kevin

David Bernard

unread,
Jan 4, 2006, 10:53:59 AM1/4/06
to TurboGears
If what you like with Stan is the way to write html, I suggest to use
formencode.htmlgen (already in TG)

(Copy from an other thread)

...
from formencode.htmlgen import html as T
...
class DivForm(TableForm):
template = str(
T.form(name="${widget.name}",
xmlns__py="http://purl.org/kid/ns#", action="${getattr(self, 'action',
None)}", method="${getattr(self, 'method', 'post')}", onsubmit="return
validateForm(this)")(
T.div(id="f_${widget.name}_errors_",
class_="formFieldErrors")(
T.span(py__if="getattr(self, errors, None)",
py__replace="getattr(self, errors, None)")
),
T.div(py__for="widget in widgets",
py__replace="XML(widget.insert(getattr(self, widget.name, None),
input_values, widget_error.get(widget.name, None)))"),
T.div(id="f_${widget.name}_actions_",
class_="formActions")(
T.input(type="submit", id="btn_save",
name="btn_save", value="save", class_="button")
),
)
)

If I've got time, I'll create a page in the wiki

Reply all
Reply to author
Forward
0 new messages