https://github.com/kpfleming/jinjanator-plugin-format-xml
Plugin for Jinjanator to allow XML-format data to be parsed and used in templates.
https://github.com/kpfleming/jinjanator-plugin-format-xml
jinja2 jinja2-cli python python3 xml
Last synced: about 2 months ago
JSON representation
Plugin for Jinjanator to allow XML-format data to be parsed and used in templates.
- Host: GitHub
- URL: https://github.com/kpfleming/jinjanator-plugin-format-xml
- Owner: kpfleming
- License: apache-2.0
- Created: 2023-08-03T13:57:42.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-14T10:54:32.000Z (8 months ago)
- Last Synced: 2024-12-14T02:48:18.041Z (6 months ago)
- Topics: jinja2, jinja2-cli, python, python3, xml
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# jinjanator-plugin-format-xml
![]()
[](https://github.com/kpfleming/jinjanator-plugin-format-xml/actions?query=workflow%3ACI%20checks)
[](https://www.python.org/downloads/release/python-3920/)
[](https://spdx.org/licenses/Apache-2.0.html)
[](https://github.com/psf/black)
[](https://github.com/python/mypy)
[](https://github.com/astral-sh/ruff)
[](https://github.com/pypa/hatch)
[](https://github.com/pytest-dev/pytest)This repo contains `jinjanator-plugin-format-xml`, a plugin which
provides an XML parser for the [jinjanator](https://github.com/kpfleming/jinjanator) tool.Open Source software: [Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html)
##
This plugin allows jinjanator to parse XML data for processing in
templates. The format can be selected using `--format xml` or
autoselected by using a data file with a name ending with `.xml`.## Installation
```
pip install jinjanator-plugin-format-xml
```## Usage
Suppose you have an NGINX configuration file template, `nginx.j2`:
```jinja2
server {
listen 80;
server_name {{ nginx.hostname }};root {{ nginx.webroot }};
index index.htm;
}
```And you have an XML file with the data, `nginx.xml`:
```xml
localhost
/var/www/project
```
This is how you render it into a working configuration file:
```bash
$ jinjanate nginx.j2 nginx.xml > nginx.conf
```## Options
* `process-namespaces`: configures the XML parser to replace namespace
references in element names with the corresponding namespaces from
`xmlns` attributes in the top-level element in the document.## Chat
If you'd like to chat with the jinjanator community, join us on
[Matrix](https://matrix.to/#/#jinjanator:km6g.us)!## Credits
["Standing on the shoulders of
giants"](https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants)
could not be more true than it is in the Python community; this
project relies on many wonderful tools and libraries produced by the
global open source software community, in addition to Python
itself. I've listed many of them below, but if I've overlooked any
please do not be offended :-)* [Black](https://github.com/psf/black)
* [Hatch-Fancy-PyPI-Readme](https://github.com/hynek/hatch-fancy-pypi-readme)
* [Hatch](https://github.com/pypa/hatch)
* [Mypy](https://github.com/python/mypy)
* [Pytest](https://github.com/pytest-dev/pytest)
* [Ruff](https://github.com/astral-sh/ruff)
* [Towncrier](https://github.com/twisted/towncrier)