Generic templating tool with support of JSON, YAML and TOML data

Overview

gotempl

Small binary used to generate files from Go Templates and data files.

The following formats are supported:

  • JSON
  • YAML
  • TOML

Usage

usage: gotempl [-h|--help] -t|--template "<value>" -d|--data "<value>"
               [-f|--format "<value>"] [-o|--output "<value>"]

               Generic templating tool

Arguments:

  -h  --help      Print help information
  -t  --template  Path to Go Template file
  -d  --data      Path to data file to use for templating
  -f  --format    Format of data file (json, yaml or toml, defaults to json).
                  Default: json
  -o  --output    Path to output file (leave empty for stdout). Default:

License

This project is released under the terms of the MIT License.

Issues
  • :sparkles: :boom: Add flag to switch from TEXT to HTML template

    :sparkles: :boom: Add flag to switch from TEXT to HTML template

    This PR provides the following changes:

    • [x] :sparkles: Add new internal package template, abstracting the builtin packages html/template and text/template
    • [x] :recycle: Refactor io package to use this new internal package
    • [x] :sparkles: Add -H / --html flag to switch implementation
    • [x] :boom: Make the text implementation the default

    Examples

    With the text implementation, the following template:

    $ cat <<EOF | gotempl
    {{ dict "foo" "bar" | toJson }}
    EOF
    

    Will produce:

    {"foo":"bar"}
    

    But with the HTML implementation, the same template:

    $ cat <<EOF | gotempl -H
    {{ dict "foo" "bar" | toJson }}
    EOF
    

    Will produce:

    {&#34;foo&#34;:&#34;bar&#34;}
    

    This was the default behavior until now, but this is obviously unexpected. Adding a function noescape would only clutter the template sources.

    opened by linkdd 0
  • 🐛 Set stdin/stdout as default file for template/output

    🐛 Set stdin/stdout as default file for template/output

    This PR aims to setup stdin/stdout to template/output argument when avoided.

    Actual Behavior

    STDIN/STDOUT ignored by default

    Desired Behavior

    STDIN/STDOUT used for template/output by default

    Changes

    • [x] set stdin as default template
    • [x] set stdout as default output
    opened by b3j0f 0
  • ✨ Add optional data files

    ✨ Add optional data files

    This PR aims to add optional data files arguments in the form --data-<format>

    • [x] : ✨ optional data file arguments
    • [x] : ✨ optional template argument (stdin by default)
    • [x] : 👕 apply best-practices
    • [x] : ✅ test coverage
    opened by b3j0f 0
Releases(v0.7.0)
Owner
Link Society
Link Society
Golang Configuration tool that support YAML, JSON, TOML, Shell Environment

Configor Golang Configuration tool that support YAML, JSON, TOML, Shell Environment (Supports Go 1.10+) Usage package main import ( "fmt" "github.c

Jinzhu 1.4k Jun 27, 2022
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.

koanf (pronounced conf; a play on the Japanese Koan) is a library for reading configuration from different sources in different formats in Go applicat

Kailash Nadh 1k Jul 6, 2022
Tmpl - A tool to apply variables from cli, env, JSON/TOML/YAML files to templates

tmpl allows to apply variables from JSON/TOML/YAML files, environment variables or CLI arguments to template files using Golang text/template and functions from the Sprig project.

krako 1 May 30, 2022
Library providing routines to merge and validate JSON, YAML and/or TOML files

CONFLATE Library providing routines to merge and validate JSON, YAML, TOML files and/or structs (godoc) Typical use case: Make your application config

Andy 25 May 5, 2022
Go-yaml - Yaml parsing Toolkit For Golang

go-yaml 介绍 gopkg.in/yaml.v3 已经是个非常好用的包,但是在实际开发中总有类型转换带来的麻烦,go-yaml只是在它的基础上,简单的一层

xiaowu 4 Jan 13, 2022
YAML support for the Go language.

YAML support for the Go language Introduction The yaml package enables Go programs to comfortably encode and decode YAML values. It was developed with

null 5.8k Jul 3, 2022
YAML support for the Go language

YAML support for the Go language

Masaaki Goshima 725 Jul 2, 2022
Golang library for reading properties from configuration files in JSON and YAML format or from environment variables.

go-config Golang library for reading properties from configuration files in JSON and YAML format or from environment variables. Usage Create config in

null 3 Feb 22, 2022
TOML parser and encoder library for Golang

TOML parser and encoder library for Golang TOML parser and encoder library for Golang. This library is compatible with TOML version v0.4.0. Installati

Naoya Inada 288 Jun 9, 2022
JSON or YAML configuration wrapper with convenient access methods.

Config Package config provides convenient access methods to configuration stored as JSON or YAML. This is a fork of the original version. This version

Oleg Lebedev 250 May 5, 2022
TOML parser for Golang with reflection.

THIS PROJECT IS UNMAINTAINED The last commit to this repo before writing this message occurred over two years ago. While it was never my intention to

Andrew Gallant 3.9k Jul 4, 2022
Go library for the TOML language

go-toml Go library for the TOML format. This library supports TOML version v1.0.0-rc.3 Features Go-toml provides the following features for using data

Thomas Pelletier 1.3k Jun 29, 2022
A better way to marshal and unmarshal YAML in Golang

YAML marshaling and unmarshaling support for Go Introduction A wrapper around go-yaml designed to enable a better way of handling YAML when marshaling

Sam Ghods 923 Jul 6, 2022
Go-config - Config parser for go that supports environment vars and multiple yaml files

go-multiconfig This package is able to parse yaml config files. It supports gett

Dimitris Tassopoulos 1 Jun 23, 2022
create a bootable disk image from Docker image or a yaml config

docker2boot docker2boot creates a bootable disk from either a Docker image or a config yaml file Features status dns Y cloud-init Y network Y ssh TODO

Bin Chen 6 Dec 21, 2021
It syncronizes the configuration described in a YAML file against your GitHub Organization

It syncronizes the configuration described in a YAML file against your GitHub Organization. Combined with a CI system, it can be used to implement GitOps for GitHub.

Carlos Tadeu Panato Junior 6 Jul 19, 2021
Golang config.yaml loader

Description goconfig is a configuration library designed using the following pri

null 2 May 31, 2022
SmartYAML - Go package to handle YAML

SmartYAML - Go package to handle YAML The smartyaml is a go package to handle parsed YAML files more confortable. This package is not a parser, it use

Péter Deák 0 Feb 25, 2022
VINYL Inscribes Nettlesome YAML Legibly

VINYL Inscribes Nettlesome YAML Legibly VINYL formats yaml files into a canonical format retaining comments and setting the indentation by default to

Jesse Hathaway 1 Jan 18, 2022