GithubHelp home page GithubHelp logo

gotmpl's Introduction

gotmpl

build status

Render golang template with command line.

templates folder has some example templates.

Install

Download gotmpl from release, and put it in your PATH.

Or build from source

go get github.com/NateScarlet/gotmpl/cmd/gotmpl

Usage

Render template to stdout

gotmpl ./template.gotmpl

Render template with data

gotmpl Key=Value ./template.gotmpl

Render template that file name has = in it.

gotmpl =./template=.gotmpl

Render to a file.

gotmpl -o ./output.txt ./template.gotmpl

Render multiple template to stdout. first template executed, others can be used with template action.

gotmpl Key=Value ./template.gotmpl ./template2.gotmpl

Read data from stdin

echo '{"Key": "Value"}' | gotmpl -i - ./template.gotmpl

Read data from file

gotmpl -i data.json ./template.gotmpl

Template

Functions

  • sprig functions
  • cwd() current working directory.
  • args() return command line argument list.
  • templateFiles() return template file list.
  • __file__() value of -o option, empty string if not specified.
  • absPath(string) convert path to absolute.
  • lowerFirst(string) lower first rune of string
  • upperFirst(string) upper first rune of string

Data

The "." object is a map[string]interface{}, so you can use set function to modify it.

There are some default data for convenient:

  • Name: index (__file__ | absPath | base | split ".") 0 if __file__ not empty
  • Package __file__ | absPath | dir | base if __file__ not empty

Data merged in order:

  • default data
  • -i file data
  • inline key value pair

gotmpl's People

Contributors

natescarlet avatar renovate-bot avatar renovate[bot] avatar

Watchers

 avatar  avatar

gotmpl's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/go.yml
  • actions/setup-go v1
  • actions/checkout v1
gomod
go.mod
  • go 1.19
  • github.com/Masterminds/sprig/v3 v3.2.3
  • github.com/huandu/xstrings v1.4.0

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

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.