Skip to main content

more.chameleon: Chameleon template integration for Morepath

more.chameleon is an extension for Morepath that adds Zope Page Template (ZPT) support for the .pt extension, using the Chameleon template engine.

For details on the ZPT template language see the Chameleon language reference.

Example usage:

from more.chameleon import ChameleonApp

class App(ChameleonApp):
    pass

@App.path(path='persons/{name}')
class Person(object):
     def __init__(self, name):
         self.name = name

@App.template_directory()
def get_template_directory():
    return 'templates'

@App.html(model=Person, template='person.pt')
def person_default(self, request):
    return {'name': self.name}

and then in person.pt (in the templates subdirectory):

<html>
<body>
<p>Hello ${name}!</p>
</body>
</html>

During development it can be helpful to have Chameleon reload templates automatically after a change. To enable this feature use the MOREPATH_TEMPLATE_AUTO_RELOAD environment variable.

You can enable it for your process:

MOREPATH_TEMPLATE_AUTO_RELOAD=1 python run.py

Or for your shell:

export MOREPATH_TEMPLATE_AUTO_RELOAD=1
python run.py

To further control Chameleon rendering you can define a chameleon setting section in your app. For instance, here is how you turn on Chameleon’s debug functionality:

@App.setting_section(section='chameleon')
def get_setting_section():
    return {'debug': True}

For details on Chameleon configuration options, consult the configuration keyword arguments in the Chameleon API reference.

CHANGES

0.2 (2016-01-23)

0.1 (2015-04-09)

  • Initial public release.

Release files for more.chameleon 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for more.chameleon 0.2
File Size Uploaded
more.chameleon-0.2.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for more.chameleon 0.2
File Interpreter ABI Platform
more.chameleon-0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.9 kB

Release files / more.chameleon-0.2.tar.gz

Download URL more.chameleon-0.2.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c09ff83687429bfa87d4e0c6b85103afad60e3804c81710068459d96824f374a
BLAKE2b-256 checksum
How to use checksums
b0f905bdb876274ae2d8927b226b0e74d971962e2ff5164815ae6aae0539c4b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / more.chameleon-0.2-py2.py3-none-any.whl

Download URL more.chameleon-0.2-py2.py3-none-any.whl
Size 8.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
db29b4146a9afb9ba00b24bf46902afd5599e18482062cac069a262cdfeb8f7b
BLAKE2b-256 checksum
How to use checksums
8d5a45393944eeb83acd38a3d65b993f7c6e6931b9a4309aa8b8cff3b3ee6462
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page