Skip to main content

A Jinja2 template loader using PyFilesystem2

Project description

A Jinja2 template loader using PyFilesystem2.

build repo versions format coverage grade license

About

This library allows you to use PyFilesystem2 as a backend to load templates into Jinja2. You can take advantage of the whole fs ecosystem, which already implements drivers for FTP, SSH, SMB, S3, WebDAV servers, ZIP and Tar archives, and many more!

Installation

Install with pip:

$ pip install --user -U jinja2-fsloader

Usage

from jinja2_fsloader import FSLoader
FSLoader(template_fs, encoding='utf-8', use_syspath=False)
template_fs

a FS instance or an FS URL where the templates are located.

encoding

the encoding of the template files (utf-8 by default).

use_syspath

set to True for the loader to return the real path or an URL to the template when available (False by default).

Examples

import jinja2
from jinja2_fsloader import FSLoader

# templates in a ZIP archive
env = jinja2.Environment(loader=FSLoader("zip:///path/to/my/templates.zip"))

# templates in a S3 bucket
env = jinja.Environment(loader=FSLoader("s3://mybucket"))

# templates in memory
mem = fs.open_fs('mem://')
mem.settext('template.j2', 'This template is {{adjective}}')
env = jinja.Environment(loader=FSLoader(mem))

See Also

The complete documentation of PyFilesystem2 can give you a better overview of all the features available in the library.

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

jinja2-fsloader-0.1.1.zip (11.3 kB view details)

Uploaded Source

Built Distribution

jinja2_fsloader-0.1.1-py2.py3-none-any.whl (8.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file jinja2-fsloader-0.1.1.zip.

File metadata

  • Download URL: jinja2-fsloader-0.1.1.zip
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for jinja2-fsloader-0.1.1.zip
Algorithm Hash digest
SHA256 b4c5edd6ccf9da82f54130c05f9393f7d7dbdd9a23caf46f8df62d0de23ff230
MD5 548e2d8059470dd11021f8ca1846f164
BLAKE2b-256 21e50f877177b7e5915437f35ad72e7397e15ec993d3a43b7cc8d60e8281f999

See more details on using hashes here.

File details

Details for the file jinja2_fsloader-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: jinja2_fsloader-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for jinja2_fsloader-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9967e537b20138c8ce510b0cb2fffd96882f1d31267e8af35b5cecf98774922a
MD5 bdd79085e3dd74bc187c9e031a27c25a
BLAKE2b-256 5978a8f1ebbc281c60509125d1f80709f247f6b0a45f84d67e4b6ede4b1dc46f

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