Skip to main content

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'}

1.0.0 (released 2020-09-27)

  • Dropped Python 2 compatibility

  • Fixed exception when calling as_string as a function decorator.

  • Fixed deprecation warnings

0.3.1 (released 2016-11-29)

0.3.0 (released 2015-09-25)

  • Added support for Kajiki

  • The environment variable has had its name changed to loader and is no longer available directly on the TemplateEnvironment object but via the plugin property. For example:

    from jinja2 import Environment, FileSystemLoader
    from fresco_template import Jinja2
    
    # Old style - BROKEN in 0.3 release:
    j2 = Jinja2(environment=Environment(FileSystemLoader('templates')))
    j2.environment.install_gettext_translations(my_translation_module)
    
    # New style:
    j2 = Jinja2(Environment(autoescape=True, FileSystemLoader('templates')))
    j2.plugin.loader.install_gettext_translations(my_translation_module)
  • Any custom plugins will need to be rewritten. Refer to any of the default plugins for examples.

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)

Metadata

Release files for fresco-template 1.0.0

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

Source distribution (sdist)

Source distribution for fresco-template 1.0.0
File Size Uploaded
fresco-template-1.0.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fresco-template 1.0.0
File Interpreter ABI Platform
fresco_template-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / fresco-template-1.0.0.tar.gz

Download URL fresco-template-1.0.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9fb3cf6fb4fecdcc47acb0a93902717474f74d02fdaee18629e11712a8c585d7
BLAKE2b-256 checksum
How to use checksums
8b822d4936070360981c111158a071b116e99caffa33c3a26dce525fb25d8164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.9

Release files / fresco_template-1.0.0-py3-none-any.whl

Download URL fresco_template-1.0.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea47b65261d37ff47f8fe3027f542894bf8f3ee84fa6f2308ccb64adbd1bfb5e
BLAKE2b-256 checksum
How to use checksums
b9a9d9026cb4b065165e30e7dfceade275b786cefe32b198a2ef2c7b64c4f0f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2

1 release file

0

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