A Skin is a manager of a related set of templates —
a skin 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 common.page(),
that will cause the site’s skin 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 skin 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 based on the
Qpy Unicode Templating package,
that provides a convenient mechanism for generating
safely-quoted html text from python code.
The other is GTi Skin, that
uses external format-agnostic template files,
that embed arbitrarily complex python expressions, with an extensible
library of python callables. These callables may be anything —
including any Qpy Template of course.
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
The base Skin class provides default implementations for
some frequently needed renderers, that are exposed to
the template evaluation namespace.
Examples include
page.crumbs(),
page.menu(),
page.crumbed_menu(),
site.link_login(),
site.link_logout(),
site.link_register(), etc.
More Information
- the Comprehensive Demo
- the package: gz.skin