Hi,
Even though it's simple to figure out by reading the source code, I
find that
on could add a small section in the widget documentation how to load
the
template from a file. See also http://docs.turbogears.org/1.0/WidgetsOverview
However, comments are disbled, and the page is immutable :( So I'll
post it here in the hopes somebody picks it up and puts it into the
docs ;)
The way I solve this task (example widget source):
# ----- Widget Source
--------------------------------------------------------
from turbogears.widgets.meta import load_kid_template
class MyWidget(widgets.Widget):
"A widget loading the template from app_name/templates/widgets/
my_widget.kid"
template_c, template =
load_kid_template("app_name.templates.widgets.my_widget")
# ----- EOF
------------------------------------------------------------------
# ----- Template Source
------------------------------------------------------
<span class="my_example_widget" xmlns:py="http://purl.org/kid/ns#">
Hello World!
</span>
# ----- EOF
------------------------------------------------------------------
One huge advantage: You can change the widget template *without*
reloading you
app! I find this very convenient.
Disadvantage: Makes it a wee bit harder to package your widget to
reuse in
other apps. But it's still doable.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---