Coder Social home page Coder Social logo

iq-scm / gotemplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coveooss/gotemplate

0.0 0.0 0.0 2.2 MB

Apply go template over files ending with .template in the current directory

License: MIT License

Shell 0.80% Go 93.66% Makefile 0.10% HTML 5.45%

gotemplate's Introduction

gotemplate

Build Status Go Report Card Documentation

Description

Apply template over files ending with .template in the current directory. Every matching *.ext.template file will render a file named *.generated.ext. It is also possible to overwrite the original files.

Functions

Supports over a hundred functions:

  • Go template
  • Sprig
  • Advanced serialization and deserialization in JSON, YAML, XML and HCL
  • Looping and flow control functions of all kinds
  • Plus a whole bunch implemented in this repository

Syntax

Supports two distinct syntaxes (usable at the same time or individually)

Here are the statements to generate the following output:

Hello
World

Note: The - character trims whitespace. Otherwise, all lines are printed out as blank lines

Regular gotemplate

{{- $test := list "Hello" "World" }}
{{- range $word := $test }}
{{ $word }}
{{- end }}

Razor

@{test} := list("Hello", "World")
@-foreach($word := $test)
@{word}
@-end foreach

Using variables

Variables can be imported from various formats (YAML, JSON and HCL) and set as CLI arguments and then used in templates. Here's an example:

vars.json

{
  "my_var": "value"
}

Script:

gotemplate --var my_var2=value2 --import vars.json '{{ .my_var }} {{ .my_var2 }}'
  >>> value value2

More examples and statement in the documentation

gotemplate's People

Contributors

cyb3rjerry avatar dblanchette avatar dependabot-preview[bot] avatar dependabot[bot] avatar dev-portal-coveo-open-source-org[bot] avatar dotboris avatar jocgir avatar jonapich avatar jplachance avatar julienduchesne avatar pballandras avatar squ1d123 avatar ycngadeu-coveo 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.