Skip to main content

Template system integration for fresco

Project description

Example usage with Jinja2:

from fresco import FrescoApp
from fresco_template import Jinja2
from jinja2 import PackageLoader

app = FrescoApp()
jinja2 = Jinja2(loader=PackageLoader('mypackage', 'template/dir'))
jinja2.init_app(app)


@jinja2.contextprocessor
def default_context():
    # Return a dictionary of variables always to be included in the
    # template context.
    #
    # NB the fresco context object and urlfor function are already included
    # in the template context by default.
    return {}

@jinja2.render('page.html')
def myview():
    return {'var': 'value'}

Same example with Chameleon:

from fresco import FrescoApp
from fresco_template import Chameleon
from chameleon import PageTemplateLoader

app = FrescoApp()

loader = PageTemplateLoader(['template/dir'], auto_reload=True)
chameleon = Chameleon(loader)
chameleon.init_app(app)


@chameleon.contextprocessor
def default_context():
    # Return a dictionary of variables always to be included in the
    # template context.
    #
    # NB the fresco context object and urlfor function are already included
    # in the template context by default.
    return {}

@chameleon.render('page.html')
def myview():
    return {'var': 'value'}

0.2.1

  • The TemplateContent class now calls all context processors on instantiation. This ensures context processors are always called before response headers are sent.

0.2

Initial release

0.1

(unreleased version)

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

fresco-template-0.2.1.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file fresco-template-0.2.1.tar.gz.

File metadata

File hashes

Hashes for fresco-template-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fd4cea5e81650ab0f31ebf5fc28ff1a1d84fe49762aa03de5ecc6100dbe7aae6
MD5 d8a09750dbbe61adf76be2b2f54d5311
BLAKE2b-256 9401d68c6a2b3c81f7dc43ff70fc7a51bc12ce1b2cdef15548f9817d41e74f15

See more details on using hashes here.

Supported by

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