# jinjarope
<div align="center">
<picture>
<img alt="JinjaRope"
src="https://raw.githubusercontent.com/phil65/jinjarope/main/docs/logo.jpg"
width="50%">
</picture>
</div>
[![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.12",
"maintainer_email": null,
"keywords": "filesystem, fsspec, internet, jinja2, markdown, templates",
"author": null,
"author_email": "Philipp Temminghoff <philipptemminghoff@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8f/7a/d991b5fe4c1f5ae0022bcf6c54190de8f7b2e58af3ec6b37f1c146c58c15/jinjarope-0.16.0.tar.gz",
"platform": null,
"description": "# jinjarope\n\n<div align=\"center\">\n <picture>\n <img alt=\"JinjaRope\"\n src=\"https://raw.githubusercontent.com/phil65/jinjarope/main/docs/logo.jpg\"\n width=\"50%\">\n </picture>\n</div>\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.16.0",
"project_urls": {
"Documentation": "https://phil65.github.io/jinjarope/",
"Source": "https://github.com/phil65/jinjarope"
},
"split_keywords": [
"filesystem",
" fsspec",
" internet",
" jinja2",
" markdown",
" templates"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "16952006c7a771525ebd2d003e9376f2e62bc918c18cd280319878b1e58c99b6",
"md5": "6e52cc7d9e3e2edd59b2668c2b706ac3",
"sha256": "4e57878505bbe1fff86785978776e029036db422d6f31be6d0aa298f7b867943"
},
"downloads": -1,
"filename": "jinjarope-0.16.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6e52cc7d9e3e2edd59b2668c2b706ac3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 2693075,
"upload_time": "2024-11-07T19:24:45",
"upload_time_iso_8601": "2024-11-07T19:24:45.918298Z",
"url": "https://files.pythonhosted.org/packages/16/95/2006c7a771525ebd2d003e9376f2e62bc918c18cd280319878b1e58c99b6/jinjarope-0.16.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8f7ad991b5fe4c1f5ae0022bcf6c54190de8f7b2e58af3ec6b37f1c146c58c15",
"md5": "d695cd01a88577302412d7fb7a960afb",
"sha256": "9c1b4cfda5d26be3f0f6a8749cd8162a4e3aef61e86a1b9d2c0cdb6521d02b51"
},
"downloads": -1,
"filename": "jinjarope-0.16.0.tar.gz",
"has_sig": false,
"md5_digest": "d695cd01a88577302412d7fb7a960afb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 2797470,
"upload_time": "2024-11-07T19:24:47",
"upload_time_iso_8601": "2024-11-07T19:24:47.662969Z",
"url": "https://files.pythonhosted.org/packages/8f/7a/d991b5fe4c1f5ae0022bcf6c54190de8f7b2e58af3ec6b37f1c146c58c15/jinjarope-0.16.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 19:24:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "phil65",
"github_project": "jinjarope",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jinjarope"
}