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
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
(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