Git Product home page Git Product logo

tpl's Introduction

tpl: render templates with data from various sources

GitHub Actions build badge Documentation Status

You want to fill data into a template file?

tpl --yaml data.yaml template.file > rendered.file

You have everything already set up in your environment and now you just want to POST it somewhere?

tpl structure.json \
  | curl \
      -X POST \
      -H "Content-Type: application/json" \
      -d@- \
      httpbin.org/anything

You want to fill in a template in your CD pipeline and have access to docker?

echo "My go-to editor is {{VISUAL}} on {{OS}}" \
  | docker run --rm -i -e "VISUAL" -e "OS=$(uname)" m3t0r/tpl -

Installation

pip install tpl, docker pull M3t0r/tpl or make install

Input sources

tpl supports multiple sources:
  • YAML files (--yaml <file>)
  • JSON files (--json <file>)
  • environment variables (--environment)

You can specify multiple sources at once, but if a key is present in more than one then it's value will be taken from the latter source. This can be useful if you have default values that you want to always be present:

tpl \
  --yaml defaults.yaml \
  --json <(curl -H "Content-Type: application/json" now.httpbin.org) \
  template.jinja2 > results.html

Usage

Usage:
  tpl [options] <template_file>
  tpl --help
  tpl --version


tpl uses the Jinja2 templating engine to render it's output. You can find the
documentation for template designers at:
    http://jinja.pocoo.org/docs/latest/templates/

If you provide multiple data sources they will be merged together. If a key is
present in more than one source the value of the source that was specified
last will be used. Nested objects will be merged with the same algorithm.

Options:
  -e, --environment    Use all environment variables as data
  --json=<file>        Load JSON data from a file or STDIN
  --yaml=<file>        Load YAML data from a file or STDIN

tpl's People

Contributors

m3t0r avatar loudambiance avatar dependabot[bot] avatar mre avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.