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.0.zip (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jinja2_fsloader-0.1.0-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: jinja2-fsloader-0.1.0.zip
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for jinja2-fsloader-0.1.0.zip
Algorithm Hash digest
SHA256 da7d7701ae6c50c51740e7687e3a1cd92926f29d9bc1b4a085e2f62e813e4d78
MD5 c2f6e54a4d428eddca835261797c4fc7
BLAKE2b-256 fa6d2a32b71bb8824942faac277cb1c69ff4baf9668ecfc10b9ddb0ba6e0c866

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jinja2_fsloader-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for jinja2_fsloader-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 075a3ca60653406f2f1c3014b76c90329da55065e66d39db5b186de9d0589f3d
MD5 d54f98c6226668a76a12e04ca43d3c69
BLAKE2b-256 ed2b2ba280ab5bdf6ff4a0dce5b019fd23ce4d249807fb07d2a97cf7e02d0738

See more details on using hashes here.

Supported by

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