Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 3.31 KB

README.md

File metadata and controls

92 lines (70 loc) · 3.31 KB

jinjanator-plugin-format-xml

Open Source Initiative Approved License logo CI Python License - Apache 2.0 Code Style - Black Types - Mypy Code Quality - Ruff Project Management - Hatch Testing - Pytest

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.

Installation

pip install jinjanator-plugin-format-xml

Usage

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

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!

Credits

"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 :-)