Machinery to include web resources based on request layer.
Project description
Overview
The package is able to include the following types of resources:
Cascading stylesheets (.css)
Kinetic stylesheets (.kss)
Javascript (.js)
Usage
The package operates with browser resources, registered individually or using the resource directory factory.
A simple example:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <include package="z3c.resourceinclude" file="meta.zcml" /> <include package="z3c.resourceinclude" /> <browser:resource name="example.css" file="example.css" /> <browser:resourceInclude layer="zope.publisher.interfaces.browser.IDefaultBrowserLayer" include="example.css" /> </configure>
This registration means that whenever the request provides IDefaultBrowserLayer the resource named ‘example.css’ will be included on the page.
To render HTML snippets that include applicable resources, a content provider is provided, see z3c/resourceinclude/provide.py. You may also use one of the viewlets:
<browser:viewlet name="resourceinclude" class="z3c.resourceinclude.viewlets.CacheOneHourViewlet" permission="zope.View" />
A convenience method is provided to require a given resource layer:
>>> from z3c.resourceinclude import include >>> include(IMyLayer)
Ordering
Resources will be included in the order they’re registered for inclusion; within an include-definition, order is respected only for resources of similar kind.
Merging
When not in ‘devmode’, the resource collector will automatically merge resources, giving them a filename based on the contents (sha digest).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file z3c.resourceinclude-0.2.2.tar.gz
.
File metadata
- Download URL: z3c.resourceinclude-0.2.2.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4125e3d4f4cd95a33d903cc31eca9144afba3964f65dec1c4dff3eacca1c85a2 |
|
MD5 | f7f92667568270b07bccdbc63ba6ea38 |
|
BLAKE2b-256 | a9018ade16ee8043eb052c2a5b58467c7d8254a5c2251dabace6151c0cd3035b |