An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# jinjanator-plugin-format-xml

Open Source Initiative Approved License logo
[![CI](https://github.com/kpfleming/jinjanator-plugin-format-xml/workflows/CI%20checks/badge.svg)](https://github.com/kpfleming/jinjanator-plugin-format-xml/actions?query=workflow%3ACI%20checks)
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-3920/)
[![License - Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-9400d3.svg)](https://spdx.org/licenses/Apache-2.0.html)
[![Code Style - Black](https://img.shields.io/badge/Code%20Style-Black-000000.svg)](https://github.com/psf/black)
[![Types - Mypy](https://img.shields.io/badge/Types-Mypy-blue.svg)](https://github.com/python/mypy)
[![Code Quality - Ruff](https://img.shields.io/badge/Code%20Quality-Ruff-red.svg)](https://github.com/astral-sh/ruff)
[![Project Management - Hatch](https://img.shields.io/badge/Project%20Management-Hatch-purple.svg)](https://github.com/pypa/hatch)
[![Testing - Pytest](https://img.shields.io/badge/Testing-Pytest-orange.svg)](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)