Skip to content

runeimp/templar

Repository files navigation

Templar

Templar Command Line Tool v2.1.0
Templar Library v0.2.1

Command line templating system written in Go. Though the initial idea was written in BASH. And that was cool; but that version had serious limitations as well. Go to the rescue!

Features

  • Mustache template system
  • POSIX style variable exansion of $VAR and ${VAR} type references in template via the prior Bash based system. See extra/templar.bash.
  • Multiple data sources available and planned
    • System environment variables
    • .env file variables
      • Automatic loading of local .env file variables
      • Option to exclude automatic loading of a local .env file
    • INI file data
    • JSON file data
    • YAML file data
    • TOML file data
    • XML file data?
    • CSV file data?
    • SQLite database query?

Usage

$ templar template.mustache
The contents of the template with {{placeholders}}
populated from the system environment and (if present)
the environment settings of a .env file.

Example

INI Files

  • Global variables are treated like normal ENV file variables.

  • Whitespace before and after keys and values is ignored.

  • Quoted values have their quotes removed but leading and trailing whitespace is preserved within the bounds of the quotes. Whitespace outside the quotes is ignored.

  • You can separate key and value with a equal sign (standard) or a colon (used in some implementations).

  • Global and DEFAULT section key/value pairs can be accessed directly {{key}} or via {{DEFAULT.key}} references.

  • To access section variables within a template the section is prepended to the sections keys. Example:

     [MySection]
     key = value

    can be accessed in a template as {{MySection.key}}. Sections and keys are case sensitive. Though that is counter to the spec it is the norm on POSIX systems.

Installation

  1. Download a release from https://github.com/runeimp/templar/releases and copy the binary to a directory in your PATH

Test Suite

Test uses Go's normal unit testing tools at this time.

Test Coverage: 78.1%

It was 83.9% but I added more stuff to test. 👼

ToDo

  • Add MVVM features so that the data input can processed into a ViewModel to limit or manipulate the input in simple ways for the View (template)
  • Complete the data input options
  • Optimize the data processing. Make it more memory friendly on constrained systems and allow for say referencing (for instance) a terabyte sized CSV file for data input.

About

Command line templating system written in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages