This repo contains jinjanator-plugin-format-xml
, a plugin which
provides an XML parser for the jinjanator tool.
Open Source software: Apache License 2.0
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
.
pip install jinjanator-plugin-format-xml
Suppose you have an NGINX configuration file template, nginx.j2
:
server {
listen 80;
server_name {{ nginx.hostname }};
root {{ nginx.webroot }};
index index.htm;
}
And you have an XML file with the data, nginx.xml
:
<nginx>
<hostname>
localhost
</hostname>
<webroot>
/var/www/project
</webroot>
</nginx>
This is how you render it into a working configuration file:
$ jinjanate nginx.j2 nginx.xml > nginx.conf
process-namespaces
: configures the XML parser to replace namespace references in element names with the corresponding namespaces fromxmlns
attributes in the top-level element in the document.
If you'd like to chat with the jinjanator community, join us on Matrix!
"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 :-)