Code Monkey home page Code Monkey logo

jinja2-fsloader's Introduction

jinja2-fsloader star me

A Jinja2 template loader using PyFilesystem2.

build repo versions changelog 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.

jinja2-fsloader's People

Contributors

althonos avatar chfw avatar dependabot-preview[bot] avatar jayvdb avatar twardoch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jayvdb moremoban

jinja2-fsloader's Issues

Use fs 2.4.9?

Hi @althonos,

Current jinja2-fsloader has version limiation: fs >=2.1.0,<2.3.0. Is there a particular reason to limit its upper version? Can it use any version beyond 2.3.0?

Thanks

sdist setup.py fails

Installing from the sdist is failing when building an rpm for openSUSE.

[   60s] + /usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s'
[   61s] Traceback (most recent call last):
[   61s]   File "setup.py", line 5, in <module>
[   61s]     setuptools.setup()
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 145, in setup
[   61s]     return distutils.core.setup(**attrs)
[   61s]   File "/usr/lib64/python2.7/distutils/core.py", line 124, in setup
[   61s]     dist.parse_config_files()
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 698, in parse_config_files
[   61s]     ignore_option_errors=ignore_option_errors)
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/config.py", line 120, in parse_configuration
[   61s]     meta.parse()
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/config.py", line 425, in parse
[   61s]     section_parser_method(section_options)
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/config.py", line 398, in parse_section
[   61s]     self[name] = value
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/config.py", line 183, in __setitem__
[   61s]     value = parser(value)
[   61s]   File "/usr/lib/python2.7/site-packages/setuptools/config.py", line 509, in _parse_version
[   61s]     raise DistutilsOptionError(tmpl.format(**locals()))
[   61s] distutils.errors.DistutilsOptionError: Version loaded from file: jinja2_fsloader/_version.txt does not comply with PEP 440:

c.f. https://build.opensuse.org/package/show/home:jayvdb:pyfs/python-jinja2-fsloader

I am able to get around the problem with a bit of sed, but others may not be so lucky.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.