# jinjarope
[![PyPI License](https://img.shields.io/pypi/l/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Package status](https://img.shields.io/pypi/status/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Daily downloads](https://img.shields.io/pypi/dd/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Weekly downloads](https://img.shields.io/pypi/dw/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Monthly downloads](https://img.shields.io/pypi/dm/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Distribution format](https://img.shields.io/pypi/format/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Wheel availability](https://img.shields.io/pypi/wheel/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Python version](https://img.shields.io/pypi/pyversions/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Implementation](https://img.shields.io/pypi/implementation/jinjarope.svg)](https://pypi.org/project/jinjarope/)
[![Releases](https://img.shields.io/github/downloads/phil65/jinjarope/total.svg)](https://github.com/phil65/jinjarope/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/jinjarope)](https://github.com/phil65/jinjarope/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/jinjarope)](https://github.com/phil65/jinjarope/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/jinjarope)](https://github.com/phil65/jinjarope/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/jinjarope)](https://github.com/phil65/jinjarope/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/jinjarope)](https://github.com/phil65/jinjarope/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/jinjarope)](https://github.com/phil65/jinjarope/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/jinjarope)](https://github.com/phil65/jinjarope/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/jinjarope)](https://github.com/phil65/jinjarope)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/jinjarope)](https://github.com/phil65/jinjarope/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/jinjarope)](https://github.com/phil65/jinjarope/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/jinjarope)](https://github.com/phil65/jinjarope)
[![Github commits this week](https://img.shields.io/github/commit-activity/w/phil65/jinjarope)](https://github.com/phil65/jinjarope)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/jinjarope)](https://github.com/phil65/jinjarope)
[![Github commits this year](https://img.shields.io/github/commit-activity/y/phil65/jinjarope)](https://github.com/phil65/jinjarope)
[![Package status](https://codecov.io/gh/phil65/jinjarope/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/jinjarope/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyUp](https://pyup.io/repos/github/phil65/jinjarope/shield.svg)](https://pyup.io/repos/github/phil65/jinjarope/)
[Read the documentation!](https://phil65.github.io/jinjarope/)
## How to install
### pip
The latest released version is available at the [Python package index](https://pypi.org/project/mknodes).
``` py
pip install jinjarope
```
With CLI:
``` py
pip install jinjarope[cli]
```
## Quick guide
Jinjarope contains a range of Jinja2 loaders (including fsspec-based ones) as well as a `jinja2.Environment` subclass with added functionality.
For debugging purposes, an FsSpec filesystem implementation for jinja2 loaders is also included.
### FsSpecFileSystemLoader
This loader can be used like a FileSystemLoader, but also works on any fsspec-supported
remote path.
Using the `dir::` prefix, any folder can be set as root.
``` py
# protocol path
loader = jinjarope.FsSpecFileSystemLoader("dir::github://phil65:jinjarope@main/tests/testresources")
env = jinjarope.Environment(loader=loader)
env.get_template("testfile.jinja").render()
# protocol and storage options
loader = jinjarope.FsSpecFileSystemLoader("github", org="phil65", repo="jinjarope")
env = jinjarope.Environment(loader=loader)
env.get_template("README.md").render()
# fsspec filesystem
fs = fsspec.filesystem("github", org="phil65", repo="jinjarope")
loader = jinjarope.FsSpecFileSystemLoader(fs)
env = jinjarope.Environment(loader=loader)
env.get_template("README.md").render()
```
### FsSpecProtocolPathLoader
This loader accepts any FsSpec protocol path to be used directly.
A complete protocol URL to the template file is required.
``` py
loader = jinjarope.FsSpecProtocolPathLoader()
env = jinjarope.Environment(loader=loader)
env.get_template("github://phil65:jinjarope@main/tests/testresources/testfile.jinja").render()
```
### NestedDictLoader
``` toml
[example]
template = "{{ something }}"
```
``` py
content = tomllib.load(toml_file)
loader = jinjarope.NestedDictLoader(content)
env = jinjarope.Environment(loader=loader)
env.get_template("example/template")
```
### General loader information
**jinjarope** also contains subclasses for all default **jinja2** loaders. These loaders
have implementations for some magic methods (`__eq__`, `__hash__`, `__repr__`, , `__getitem__`).
``` py
loader = jinjarope.FileSystemLoader(...)
template_source = loader["path/to/template.jinja"]
```
The loaders can also get ORed to return a ChoiceLoader.
``` py
choice_loader = jinjarope.FileSystemLoader(..) | jinjarope.PackageLoader(...)
```
Prefix loaders can get created using pathlib-style string concatenations
``` py
prefix_loader = "path_prefix" / jinjarope.FileSystemLoader(...)
```
### Additional filters / tests
Check out the documentation for a list of built-in filters and tests!
Raw data
{
"_id": null,
"home_page": null,
"name": "jinjarope",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "filesystem,fsspec,internet,jinja2,templates",
"author": null,
"author_email": "Philipp Temminghoff <philipptemminghoff@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e6/95/37f41d14e9346083e7ecbdd1eda8fb6eb0beb65c8c236743e54ae74528f0/jinjarope-0.11.5.tar.gz",
"platform": null,
"description": "# jinjarope\n\n[![PyPI License](https://img.shields.io/pypi/l/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Package status](https://img.shields.io/pypi/status/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Daily downloads](https://img.shields.io/pypi/dd/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Weekly downloads](https://img.shields.io/pypi/dw/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Monthly downloads](https://img.shields.io/pypi/dm/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Distribution format](https://img.shields.io/pypi/format/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Wheel availability](https://img.shields.io/pypi/wheel/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Python version](https://img.shields.io/pypi/pyversions/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Implementation](https://img.shields.io/pypi/implementation/jinjarope.svg)](https://pypi.org/project/jinjarope/)\n[![Releases](https://img.shields.io/github/downloads/phil65/jinjarope/total.svg)](https://github.com/phil65/jinjarope/releases)\n[![Github Contributors](https://img.shields.io/github/contributors/phil65/jinjarope)](https://github.com/phil65/jinjarope/graphs/contributors)\n[![Github Discussions](https://img.shields.io/github/discussions/phil65/jinjarope)](https://github.com/phil65/jinjarope/discussions)\n[![Github Forks](https://img.shields.io/github/forks/phil65/jinjarope)](https://github.com/phil65/jinjarope/forks)\n[![Github Issues](https://img.shields.io/github/issues/phil65/jinjarope)](https://github.com/phil65/jinjarope/issues)\n[![Github Issues](https://img.shields.io/github/issues-pr/phil65/jinjarope)](https://github.com/phil65/jinjarope/pulls)\n[![Github Watchers](https://img.shields.io/github/watchers/phil65/jinjarope)](https://github.com/phil65/jinjarope/watchers)\n[![Github Stars](https://img.shields.io/github/stars/phil65/jinjarope)](https://github.com/phil65/jinjarope/stars)\n[![Github Repository size](https://img.shields.io/github/repo-size/phil65/jinjarope)](https://github.com/phil65/jinjarope)\n[![Github last commit](https://img.shields.io/github/last-commit/phil65/jinjarope)](https://github.com/phil65/jinjarope/commits)\n[![Github release date](https://img.shields.io/github/release-date/phil65/jinjarope)](https://github.com/phil65/jinjarope/releases)\n[![Github language count](https://img.shields.io/github/languages/count/phil65/jinjarope)](https://github.com/phil65/jinjarope)\n[![Github commits this week](https://img.shields.io/github/commit-activity/w/phil65/jinjarope)](https://github.com/phil65/jinjarope)\n[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/jinjarope)](https://github.com/phil65/jinjarope)\n[![Github commits this year](https://img.shields.io/github/commit-activity/y/phil65/jinjarope)](https://github.com/phil65/jinjarope)\n[![Package status](https://codecov.io/gh/phil65/jinjarope/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/jinjarope/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyUp](https://pyup.io/repos/github/phil65/jinjarope/shield.svg)](https://pyup.io/repos/github/phil65/jinjarope/)\n\n[Read the documentation!](https://phil65.github.io/jinjarope/)\n\n## How to install\n\n### pip\n\nThe latest released version is available at the [Python package index](https://pypi.org/project/mknodes).\n\n``` py\npip install jinjarope\n```\nWith CLI:\n\n``` py\npip install jinjarope[cli]\n```\n\n\n## Quick guide\n\nJinjarope contains a range of Jinja2 loaders (including fsspec-based ones) as well as a `jinja2.Environment` subclass with added functionality.\n\nFor debugging purposes, an FsSpec filesystem implementation for jinja2 loaders is also included.\n\n\n### FsSpecFileSystemLoader\n\nThis loader can be used like a FileSystemLoader, but also works on any fsspec-supported\nremote path.\nUsing the `dir::` prefix, any folder can be set as root.\n\n``` py\n# protocol path\nloader = jinjarope.FsSpecFileSystemLoader(\"dir::github://phil65:jinjarope@main/tests/testresources\")\nenv = jinjarope.Environment(loader=loader)\nenv.get_template(\"testfile.jinja\").render()\n\n# protocol and storage options\nloader = jinjarope.FsSpecFileSystemLoader(\"github\", org=\"phil65\", repo=\"jinjarope\")\nenv = jinjarope.Environment(loader=loader)\nenv.get_template(\"README.md\").render()\n\n# fsspec filesystem\nfs = fsspec.filesystem(\"github\", org=\"phil65\", repo=\"jinjarope\")\nloader = jinjarope.FsSpecFileSystemLoader(fs)\nenv = jinjarope.Environment(loader=loader)\nenv.get_template(\"README.md\").render()\n```\n\n\n### FsSpecProtocolPathLoader\n\nThis loader accepts any FsSpec protocol path to be used directly.\nA complete protocol URL to the template file is required.\n\n``` py\nloader = jinjarope.FsSpecProtocolPathLoader()\nenv = jinjarope.Environment(loader=loader)\nenv.get_template(\"github://phil65:jinjarope@main/tests/testresources/testfile.jinja\").render()\n```\n\n\n### NestedDictLoader\n\n``` toml\n[example]\ntemplate = \"{{ something }}\"\n```\n``` py\ncontent = tomllib.load(toml_file)\nloader = jinjarope.NestedDictLoader(content)\nenv = jinjarope.Environment(loader=loader)\nenv.get_template(\"example/template\")\n```\n\n\n### General loader information\n\n**jinjarope** also contains subclasses for all default **jinja2** loaders. These loaders\nhave implementations for some magic methods (`__eq__`, `__hash__`, `__repr__`, , `__getitem__`).\n\n``` py\nloader = jinjarope.FileSystemLoader(...)\ntemplate_source = loader[\"path/to/template.jinja\"]\n```\n\nThe loaders can also get ORed to return a ChoiceLoader.\n\n``` py\nchoice_loader = jinjarope.FileSystemLoader(..) | jinjarope.PackageLoader(...)\n```\n\nPrefix loaders can get created using pathlib-style string concatenations\n\n``` py\nprefix_loader = \"path_prefix\" / jinjarope.FileSystemLoader(...)\n```\n\n### Additional filters / tests\n\nCheck out the documentation for a list of built-in filters and tests!\n",
"bugtrack_url": null,
"license": null,
"summary": "Jinja2 utilities, loaders & fsspec integration.",
"version": "0.11.5",
"project_urls": {
"Documentation": "https://phil65.github.io/jinjarope/",
"Source": "https://github.com/phil65/jinjarope"
},
"split_keywords": [
"filesystem",
"fsspec",
"internet",
"jinja2",
"templates"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b0777789174195acff4ddd5ecc197e30727b5467c6062a444b73401eee4fa04b",
"md5": "3e398799788926faaa6cd742a70dfff9",
"sha256": "479e8be98c9829f2ada9a206560507bdaea8c954823d96659c6b5743b4ba07c3"
},
"downloads": -1,
"filename": "jinjarope-0.11.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e398799788926faaa6cd742a70dfff9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 53756,
"upload_time": "2023-12-15T01:53:57",
"upload_time_iso_8601": "2023-12-15T01:53:57.190954Z",
"url": "https://files.pythonhosted.org/packages/b0/77/7789174195acff4ddd5ecc197e30727b5467c6062a444b73401eee4fa04b/jinjarope-0.11.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e69537f41d14e9346083e7ecbdd1eda8fb6eb0beb65c8c236743e54ae74528f0",
"md5": "29f425c1c2ab0dbf6d4bf3ed58b875fb",
"sha256": "2c9cbc57768f4173155b89453dcda615ad4fc436a814602811c8efafd2118ca8"
},
"downloads": -1,
"filename": "jinjarope-0.11.5.tar.gz",
"has_sig": false,
"md5_digest": "29f425c1c2ab0dbf6d4bf3ed58b875fb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 55237,
"upload_time": "2023-12-15T01:53:55",
"upload_time_iso_8601": "2023-12-15T01:53:55.387020Z",
"url": "https://files.pythonhosted.org/packages/e6/95/37f41d14e9346083e7ecbdd1eda8fb6eb0beb65c8c236743e54ae74528f0/jinjarope-0.11.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-15 01:53:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "phil65",
"github_project": "jinjarope",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jinjarope"
}