GithubHelp home page GithubHelp logo

tera-cli's Introduction

Tera CLI

CI Status Crates.io License: MIT

Tera CLI for one-off template interpolation from context file / env vars.

The following context formats are supported:

  • JSON context file (--json . defaults to .tera.json)
  • TOML context file (--toml . defaults to .tera.toml)
  • YAML context file (--yaml . defaults to .tera.yaml)
  • Environment variables

Changelog

See CHANGELOG.md.

Simple Examples

TOML

Template template.tmpl

{% if hello %}{{ msg }}{% endif %}

TOML .tera.toml

hello = true
msg = "Hello World!"

STDOUT

> tera -f template.tmpl --toml .
Hello World!

> cat template.tmpl | tera --toml .
Hello World!

> tera -s "$(cat template.tmpl)" --toml .
Hello World!

Environment Variables

Template template.tmpl

{% if MSG %}{{ MSG }}{% endif %}

STDOUT

> MSG="Hello World!" tera -f template.tmpl --env
Hello World!

By default, setting --toml . looks for .tera.toml context file in current working directory. Similarly, setting --json . looks for .tera.json in current working directory. Use --toml file_to_toml to change the path to the context file.

For more details, run

tera --help

Acknowledgement

Thanks to original Tera author, whose GitHub repository is at: https://github.com/Keats/tera.

Also thanks to BurntSushi and his ripgrep repository showcase of GitHub Actions for cross-compilation, which has been copied and adapted heavily into this repository. The original files are here: https://github.com/BurntSushi/ripgrep/tree/8905d54a9f25f4c1e4e3ca8331f517473e174d87/.github/workflows.

tera-cli's People

Contributors

atcol avatar guangie88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tera-cli's Issues

Add Fluent language functions

I have a need for a CLI tool tool that not only implements data templating but also gives access to localizations through Fluent. There are several tools for the Handlebars ecosystem (at least JS and Rust ones that I'm aware of) that make this possible but I would prefer to use Tera if possible. There doesn't seem to be anything out there yet, but the fluent_templates crate already has support for use as a Tera function, so it shouldn't be hard to bring the existing library functionality to a CLI.

Is this project interested in adding this functionality (either as a default feature or behind a feature flag), or should I consider forking or creating an all new project for this?

c.f. chevdor/tera-cli#20

Failure to render HOST environment variable

When running tera -s "{{ HOST }}" --env I get the following error:

Tera application error: Failed to render '__tera_one_off'

Other variables seem to work fine

$ tera -s "{{ EDITOR }}" --env
nvim%

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.