Skip to main content

Machinery to include web resources based on request layer.

Project description

Overview

  • 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.

A convenience method is provided to require a given resource layer:

>>> from z3c.resourceinclude import provide
>>> provide(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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z3c.resourceinclude-0.1.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file z3c.resourceinclude-0.1.tar.gz.

File metadata

File hashes

Hashes for z3c.resourceinclude-0.1.tar.gz
Algorithm Hash digest
SHA256 c82cafead247450571bcb892616cebb8aa5e294cff1c76b8860a8c68ec9a0f78
MD5 cfb480928d9d18de34ccdf3666b7e774
BLAKE2b-256 262e077ec56d9de8dd757aef80a2d39f3d8be75dfa72ee7fbb19fdbca2af5646

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page