Coder Social home page Coder Social logo

fuadarradhi / gonja Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nikolalohinski/gonja

0.0 0.0 0.0 412 KB

⛩️ Pure Golang engine for Jinja templates

Home Page: https://pkg.go.dev/github.com/nikolalohinski/gonja

License: MIT License

Go 100.00%

gonja's Introduction

gonja

gonja is a pure go implementation of the Jinja template engine. It aims to be mostly compatible with the original python implementation but also provides additional features to compensate the lack of python scripting capabilities.

Usage

As a library

Install/update using go get:

go get github.com/nikolalohinski/gonja

As a terraform provider

This gonja library has been packaged as a terraform provider. For more information, please refer to the dedicated documentation.

Example

package main

import (
	"fmt"

	"github.com/nikolalohinski/gonja"
)

func main() {
	tpl, err := gonja.FromString("Hello {{ name | capitalize }}!")
	if err != nil {
		panic(err)
	}
	out, err := tpl.Execute(gonja.Context{"name": "bob"})
	if err != nil {
		panic(err)
	}
	fmt.Println(out) // Prints: Hello Bob!
}

Documentation

Limitations

  • format: format does not take Python's string format syntax as a parameter, instead it takes Go's. Essentially {{ 3.14|stringformat:"pi is %.2f" }} is fmt.Sprintf("pi is %.2f", 3.14).
  • escape / force_escape: Unlike Jinja's behavior, the escape-filter is applied immediately. Therefore there is no need for a force_escape-filter yet.

Tribute

A massive thank you to the original author @noirbizarre for doing the initial work in https://github.com/noirbizarre/gonja which this project was forked from.

gonja's People

Contributors

nikolalohinski avatar noirbizarre avatar nvartolomei 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.