Gizmo(QP) Templating

A Templating, or Skin, is a manager of a related set of templates -- it defines page templates, in accordance with its own meaning of what a page template is, and manages their invocation. To respond, an export (that is a web accessible object or method, in QP parlance) need only call gz.pub.common.page(), that will cause the site's templating to delegate the generation of the formatted page to the right page template.

At initialization, the Publisher.skin attribute is set with a newly created templating instance, as returned by Publisher.skin_class(). There is an abstract base Skin class, on which concrete Skins are based. Currently, Gizmo(QP) offers two predefined Skins.

The first, QpySkin, is directly based on the Qpy Unicode Templating package, that provides a convenient mechanism for generating safely-quoted html text from python code.

The other is EvoqueTemplating and provides the necessary integration between Gizmo(QP) and the full-featured Evoque Templating engine.

To create another kind of Skin altogether, such as one that defines another kind of template, or uses a different templating package, you subclass the base Skin class.

Clean HTML output

To make complex dhtml pages easier to manage, a page may make use of a dhi instance, to which complex page objects such as gizmos can contribute to. The base Skin class takes care of dhi rendering, also making sure that it is rendered last -- so that it can be contributed to at any time during page generation.

As a consequence, the dhtml rendering of a page that uses a dhi instance has a maximum of one inlined script tag and has a maximum of one inlined style tag. This makes such complex pages easier to debug as well as simpler to render by the client.

Default renderers

Default implementations for some frequently needed renderers are provided as stand-alone modules. Callables from these are exposed to the template evaluation namespace, under the namespaces site, page, gizmo, html. Examples include page.crumbs(), page.menu(), page.crumbed_menu(), site.link_login(), site.link_logout(), site.link_register(), etc.

More Information