Toothpaste is a simple templating engine for Go web applications, inspired by Blade/Twig

toothpaste

Toothpaste is a simple templating engine for Go web applications, inspired by Blade/Twig. It supports basic if-statements, variables, inline variable definitions, variable HTML sanitization by default (but also allows raw printing), recursive template importing with context and processing functions.

Variables can be a string, int, int8, int16, int64 and func(ctx *RenderContext) string. Variable types (or processors) will be resolved everytime a variable is invoked from your template. You can use functions to process scripts during rendering.

example:

var context = NewRenderContext()
context.SetVariable("user_state", func(ctx *RenderContext) string {
    // check if the user is logged in, and return the state
    return "logged_in"
})

context.SetVariable("name", "Mats")
You are logged in! welcome back to {{ @app_name }}, {{ @name }}! {% end %} {% if @user_state not logged_in %}

You seem to be new! please login.

your state is {{ @user_state }}

{% end %} {{ include(footer) }} ">
{{ include(navbar) }}

{% set app_name "My cool app!" %}

{% if @user_state is logged_in %}
    <h1>You are logged in! welcome back to {{ @app_name }}, {{ @name }}!h1>
{% end %}
{% if @user_state not logged_in %}
    <h1>You seem to be new! please <a href="/login">logina>.h1>
    <p>your state is {{ @user_state }}p>
{% end %}

{{ include(footer) }}

Examples

Owner
Mats
Student by day and night, engineer, actually, also by night! turns out to be quite the problem
Mats
Similar Resources

Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural conversations

GoSpin Article spinning and spintax/spinning syntax engine written in Go, useful for A/B, testing pieces of text/articles and creating more natural co

Dec 22, 2022

A handy, fast and powerful go template engine.

A handy, fast and powerful go template engine.

Hero Hero is a handy, fast and powerful go template engine, which pre-compiles the html templates to go code. It has been used in production environme

Dec 27, 2022

Jet template engine

Jet Template Engine for Go Jet is a template engine developed to be easy to use, powerful, dynamic, yet secure and very fast. simple and familiar synt

Jan 4, 2023

A complete Liquid template engine in Go

A complete Liquid template engine in Go

Liquid Template Parser liquid is a pure Go implementation of Shopify Liquid templates. It was developed for use in the Gojekyll port of the Jekyll sta

Dec 15, 2022

Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths. Up to 20x faster than html/template

quicktemplate A fast, powerful, yet easy to use template engine for Go. Inspired by the Mako templates philosophy. Features Extremely fast. Templates

Dec 26, 2022

Razor view engine for go

gorazor gorazor is the Go port of the razor view engine originated from asp.net in 2011. In summary, gorazor is: Extremely Fast. Templates are convert

Dec 25, 2022

gtpl is a template engine for glang

gtpl 使用必读 gtpl is a HTML template engine for golang gtpl 是一个 go 语言模板引擎,它能以极快的速度进行模板语法分析。相比 go 语言官方库 html/template,gtpl 的语法有着简练、灵活、易用的特点。

Nov 28, 2022

The world’s most powerful template engine and Go embeddable interpreter.

The world’s most powerful template engine and Go embeddable interpreter.

The world’s most powerful template engine and Go embeddable interpreter

Dec 23, 2022

This my project template for making fiber with SSR taste by empowered mustache engine.

SSR-FIBER-TEMPLATE This my project template for making fiber with SSR taste by empowered mustache engine. Folder Hierarchy Name Description configs Co

May 9, 2022
pongo2 is a Django-syntax like templating-language

Django-syntax like template-engine for Go

Dec 27, 2022
An ERB-style templating language for Go.

Ego Ego is an ERb style templating language for Go. It works by transpiling templates into pure Go and including them at compile time. These templates

Jan 6, 2023
Templating system for HTML and other text documents - go implementation

FAQ What is Kasia.go? Kasia.go is a Go implementation of the Kasia templating system. Kasia is primarily designed for HTML, but you can use it for any

Mar 15, 2022
A sweet velvety templating package

Velvet Velvet is a templating package for Go. It bears a striking resemblance to "handlebars" based templates, there are a few small changes/tweaks, t

Nov 28, 2022
A strongly typed HTML templating language that compiles to Go code, and has great developer tooling.
A strongly typed HTML templating language that compiles to Go code, and has great developer tooling.

A language, command line tool and set of IDE extensions that makes it easier to write HTML user interfaces and websites using Go.

Dec 29, 2022
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.
A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.

Maroto A Maroto way to create PDFs. Maroto is inspired in Bootstrap and uses Gofpdf. Fast and simple. Maroto definition: Brazilian expression, means a

Jan 7, 2023
Simple and fast template engine for Go

fasttemplate Simple and fast template engine for Go. Fasttemplate performs only a single task - it substitutes template placeholders with user-defined

Dec 30, 2022
A go template repository for easily bootstrapping new go applications

Template go Repository tl;dr This is a template go repository with actions already set up to create compiled releases What does this Template provide?

Nov 5, 2021
Code your next Go web project with (a) Mojito! No matter if its an API or a website, go-mojito assists you with dependency injection, simple routing, custom request / response objects and template rendering
 Code your next Go web project with (a) Mojito! No matter if its an API or a website, go-mojito assists you with dependency injection, simple routing, custom request / response objects and template rendering

Go-Mojito is a super-modular library to bootstrap your next Go web project. It can be used for strict API-only purposes as well as server-side renderi

May 1, 2022
HTML template engine for Go

Ace - HTML template engine for Go Overview Ace is an HTML template engine for Go. This is inspired by Slim and Jade. This is a refinement of Gold. Exa

Jan 4, 2023