# jinjarope
<div align="center">
<picture>
<img alt="JinjaRope"
src="https://raw.githubusercontent.com/phil65/jinjarope/main/docs/logo.jpg"
width="50%">
</picture>
</div>
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://pypi.org/project/jinjarope/)
[](https://github.com/phil65/jinjarope/releases)
[](https://github.com/phil65/jinjarope/graphs/contributors)
[](https://github.com/phil65/jinjarope/discussions)
[](https://github.com/phil65/jinjarope/forks)
[](https://github.com/phil65/jinjarope/issues)
[](https://github.com/phil65/jinjarope/pulls)
[](https://github.com/phil65/jinjarope/watchers)
[](https://github.com/phil65/jinjarope/stars)
[](https://github.com/phil65/jinjarope)
[](https://github.com/phil65/jinjarope/commits)
[](https://github.com/phil65/jinjarope/releases)
[](https://github.com/phil65/jinjarope)
[](https://github.com/phil65/jinjarope)
[](https://github.com/phil65/jinjarope)
[](https://github.com/phil65/jinjarope)
[](https://codecov.io/gh/phil65/jinjarope/)
[](https://github.com/psf/black)
[](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/cd/78/81e9e650551aaadee293cd93444b6447cf87d87b5aa8d675fb56134ee288/jinjarope-0.16.2.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[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://pypi.org/project/jinjarope/)\n[](https://github.com/phil65/jinjarope/releases)\n[](https://github.com/phil65/jinjarope/graphs/contributors)\n[](https://github.com/phil65/jinjarope/discussions)\n[](https://github.com/phil65/jinjarope/forks)\n[](https://github.com/phil65/jinjarope/issues)\n[](https://github.com/phil65/jinjarope/pulls)\n[](https://github.com/phil65/jinjarope/watchers)\n[](https://github.com/phil65/jinjarope/stars)\n[](https://github.com/phil65/jinjarope)\n[](https://github.com/phil65/jinjarope/commits)\n[](https://github.com/phil65/jinjarope/releases)\n[](https://github.com/phil65/jinjarope)\n[](https://github.com/phil65/jinjarope)\n[](https://github.com/phil65/jinjarope)\n[](https://github.com/phil65/jinjarope)\n[](https://codecov.io/gh/phil65/jinjarope/)\n[](https://github.com/psf/black)\n[](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.2",
"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": "06df39e777e5f32d068a0a6f9cb0dd612ba6b38bce16798d0a8dc8920d663912",
"md5": "db81335641314c0180158da4c87110c7",
"sha256": "2375d3311f1878812faa46ef5967aeb9bbfc979068311308ff11966572559aa7"
},
"downloads": -1,
"filename": "jinjarope-0.16.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "db81335641314c0180158da4c87110c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 2693174,
"upload_time": "2025-02-17T23:40:57",
"upload_time_iso_8601": "2025-02-17T23:40:57.310681Z",
"url": "https://files.pythonhosted.org/packages/06/df/39e777e5f32d068a0a6f9cb0dd612ba6b38bce16798d0a8dc8920d663912/jinjarope-0.16.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cd7881e9e650551aaadee293cd93444b6447cf87d87b5aa8d675fb56134ee288",
"md5": "2c54ad79190c7684cee0b5774ac1cc2b",
"sha256": "914c9af996e0c4d8a3c1fca42aa872900abd7bc6b8f15022c9028e4b76493c11"
},
"downloads": -1,
"filename": "jinjarope-0.16.2.tar.gz",
"has_sig": false,
"md5_digest": "2c54ad79190c7684cee0b5774ac1cc2b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 2797529,
"upload_time": "2025-02-17T23:41:02",
"upload_time_iso_8601": "2025-02-17T23:41:02.937942Z",
"url": "https://files.pythonhosted.org/packages/cd/78/81e9e650551aaadee293cd93444b6447cf87d87b5aa8d675fb56134ee288/jinjarope-0.16.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-17 23:41:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "phil65",
"github_project": "jinjarope",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jinjarope"
}