All Projects → valyala → Fasttemplate

valyala / Fasttemplate

Licence: mit
Simple and fast template engine for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Fasttemplate

Victoriametrics
VictoriaMetrics: fast, cost-effective monitoring solution and time series database
Stars: ✭ 5,558 (+1082.55%)
Mutual labels:  fast
React Native Blurhash
🖼️ A library to show colorful blurry placeholders while your content loads.
Stars: ✭ 430 (-8.51%)
Mutual labels:  placeholder
Uikit Ecommerce Template
E-commerce template built with UIKIt
Stars: ✭ 453 (-3.62%)
Mutual labels:  template
Flasksaas
A great starting point to build your SaaS in Flask & Python, with Stripe subscription billing 🚀
Stars: ✭ 412 (-12.34%)
Mutual labels:  template
Httpteleport
Transfer 10Gbps http traffic over 1Gbps networks :)
Stars: ✭ 422 (-10.21%)
Mutual labels:  fast
Xorstr
heavily vectorized c++17 compile time string encryption.
Stars: ✭ 435 (-7.45%)
Mutual labels:  template
Esm.sh
A fast, global content delivery network for ES Modules.
Stars: ✭ 404 (-14.04%)
Mutual labels:  fast
Badgen
Fast handcraft svg badge generator.
Stars: ✭ 464 (-1.28%)
Mutual labels:  fast
React Native Template Rocketseat Basic
Template básica para aplicações React Native com a estrutura utilizada na Rocketseat 🚀
Stars: ✭ 431 (-8.3%)
Mutual labels:  template
Nestjs Bff
A full-stack TypeScript solution, and starter project. Includes an API, CLI, and example client webapp. Features include production grade logging, authorization, authentication, MongoDB migrations, and end-to-end testing.
Stars: ✭ 450 (-4.26%)
Mutual labels:  template
Wyhash
The FASTEST QUALITY hash function, random number generators (PRNG) and hash map.
Stars: ✭ 410 (-12.77%)
Mutual labels:  fast
Koa Rest Api Boilerplate
💯 Boilerplate for Node.js Koa RESTful API application with Docker, Swagger, Jest, CodeCov and CircleCI
Stars: ✭ 420 (-10.64%)
Mutual labels:  template
Okdownload
A Reliable, Flexible, Fast and Powerful download engine.
Stars: ✭ 4,478 (+852.77%)
Mutual labels:  fast
Kdbush
A fast static index for 2D points
Stars: ✭ 412 (-12.34%)
Mutual labels:  fast
Orientdb
OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries. OrientDB Community Edition is Open Source using a liberal Apache 2 license.
Stars: ✭ 4,394 (+834.89%)
Mutual labels:  fast
Lizard
Lizard (formerly LZ5) is an efficient compressor with very fast decompression. It achieves compression ratio that is comparable to zip/zlib and zstd/brotli (at low and medium compression levels) at decompression speed of 1000 MB/s and faster.
Stars: ✭ 408 (-13.19%)
Mutual labels:  fast
Asp Net Core Vue Starter
ASP.NET Core + Vue.js starter project
Stars: ✭ 436 (-7.23%)
Mutual labels:  template
Fastlib
一个Android项目级快速开发框架,节约大部分写常用功能时间以实现更多项目业务功能及体验上的优化。使用说明见wiki
Stars: ✭ 469 (-0.21%)
Mutual labels:  fast
React Native Template Rocketseat Advanced
Template avançada para aplicações React Native com a estrutura utilizada na Rocketseat 🚀
Stars: ✭ 459 (-2.34%)
Mutual labels:  template
Landing Page
Tailwind CSS Starter Template - Landing Page
Stars: ✭ 444 (-5.53%)
Mutual labels:  template

fasttemplate

Simple and fast template engine for Go.

Fasttemplate performs only a single task - it substitutes template placeholders with user-defined values. At high speed :)

Take a look at quicktemplate if you need fast yet powerful html template engine.

Please note that fasttemplate doesn't do any escaping on template values unlike html/template do. So values must be properly escaped before passing them to fasttemplate.

Fasttemplate is faster than text/template, strings.Replace, strings.Replacer and fmt.Fprintf on placeholders' substitution.

Below are benchmark results comparing fasttemplate performance to text/template, strings.Replace, strings.Replacer and fmt.Fprintf:

$ go test -bench=. -benchmem
PASS
BenchmarkFmtFprintf-4                   	 2000000	       790 ns/op	       0 B/op	       0 allocs/op
BenchmarkStringsReplace-4               	  500000	      3474 ns/op	    2112 B/op	      14 allocs/op
BenchmarkStringsReplacer-4              	  500000	      2657 ns/op	    2256 B/op	      23 allocs/op
BenchmarkTextTemplate-4                 	  500000	      3333 ns/op	     336 B/op	      19 allocs/op
BenchmarkFastTemplateExecuteFunc-4      	 5000000	       349 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastTemplateExecute-4          	 3000000	       383 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastTemplateExecuteFuncString-4	 3000000	       549 ns/op	     144 B/op	       1 allocs/op
BenchmarkFastTemplateExecuteString-4    	 3000000	       572 ns/op	     144 B/op	       1 allocs/op
BenchmarkFastTemplateExecuteTagFunc-4   	 2000000	       743 ns/op	     144 B/op	       3 allocs/op

Docs

See http://godoc.org/github.com/valyala/fasttemplate .

Usage

	template := "http://{{host}}/?q={{query}}&foo={{bar}}{{bar}}"
	t := fasttemplate.New(template, "{{", "}}")
	s := t.ExecuteString(map[string]interface{}{
		"host":  "google.com",
		"query": url.QueryEscape("hello=world"),
		"bar":   "foobar",
	})
	fmt.Printf("%s", s)

	// Output:
	// http://google.com/?q=hello%3Dworld&foo=foobarfoobar

Advanced usage

	template := "Hello, [user]! You won [prize]!!! [foobar]"
	t, err := fasttemplate.NewTemplate(template, "[", "]")
	if err != nil {
		log.Fatalf("unexpected error when parsing template: %s", err)
	}
	s := t.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
		switch tag {
		case "user":
			return w.Write([]byte("John"))
		case "prize":
			return w.Write([]byte("$100500"))
		default:
			return w.Write([]byte(fmt.Sprintf("[unknown tag %q]", tag)))
		}
	})
	fmt.Printf("%s", s)

	// Output:
	// Hello, John! You won $100500!!! [unknown tag "foobar"]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].