1- # gtmpl-rust – Golang Templates for Rust
1+ # gtmpl-ng – Golang Templates for Rust
22
33[ ![ Latest Version]] [ crates.io ]
44
5- [ Latest Version ] : https://img.shields.io/crates/v/gtmpl.svg
6- [ crates.io ] : https://crates.io/crates/gtmpl
5+ [ Latest Version ] : https://img.shields.io/crates/v/gtmpl-ng .svg
6+ [ crates.io ] : https://crates.io/crates/gtmpl-ng
77
88---
99
10- [ gtmpl-rust] provides the [ Golang text/template] engine for Rust. This enables
10+ This is a fork of [ gtmpl-rust] with a fix for incorrect line number tracking in error messages.
11+
12+ [ gtmpl-ng] provides the [ Golang text/template] engine for Rust. This enables
1113seamless integration of Rust application into the world of devops tools around
1214[ kubernetes] , [ docker] and whatnot.
1315
@@ -16,12 +18,12 @@ seamless integration of Rust application into the world of devops tools around
1618Add the following dependency to your Cargo manifest…
1719``` toml
1820[dependencies ]
19- gtmpl = " 0.7"
21+ gtmpl-ng = " 0.7"
2022```
2123
2224and look at the docs:
23- * [ gtmpl at crates.io] ( https://crates.io/crates/gtmpl )
24- * [ gtmpl documentation] ( https://docs.rs/crate/gtmpl )
25+ * [ gtmpl-ng at crates.io] ( https://crates.io/crates/gtmpl-ng )
26+ * [ gtmpl-ng documentation] ( https://docs.rs/crate/gtmpl-ng )
2527* [ golang documentation] ( https://golang.org/pkg/text/template/ )
2628
2729
@@ -31,7 +33,7 @@ It's not perfect, yet. Help and feedback is more than welcome.
3133
3234Basic template:
3335``` rust
34- use gtmpl;
36+ use gtmpl_ng as gtmpl;
3537
3638fn main () {
3739 let output = gtmpl :: template (" Finally! Some {{ . }} for Rust" , " gtmpl" );
@@ -42,7 +44,7 @@ fn main() {
4244Adding custom functions:
4345``` rust
4446use gtmpl_value :: Function ;
45- use gtmpl :: {FuncError , gtmpl_fn, template, Value };
47+ use gtmpl_ng :: {FuncError , gtmpl_fn, template, Value };
4648
4749fn main () {
4850 gtmpl_fn! (
@@ -65,7 +67,7 @@ struct Foo {
6567
6668fn main () {
6769 let foo = Foo { bar : 42 };
68- let output = gtmpl :: template (" The answer is: {{ .bar }}" , foo );
70+ let output = gtmpl_ng :: template (" The answer is: {{ .bar }}" , foo );
6971 assert_eq! (& output . unwrap (), " The answer is: 42" );
7072}
7173```
@@ -74,7 +76,7 @@ Invoking a *method* on a context:
7476``` rust
7577
7678use gtmpl_derive :: Gtmpl ;
77- use gtmpl :: {Func , FuncError , Value };
79+ use gtmpl_ng :: {Func , FuncError , Value };
7880
7981fn plus_one (args : & [Value ]) -> Result <Value , FuncError > {
8082 if let Value :: Object (ref o ) = & args [0 ] {
@@ -95,7 +97,7 @@ struct AddMe {
9597
9698fn main () {
9799 let add_me = AddMe { num : 42 , plus_one };
98- let output = gtmpl :: template (" The answer is: {{ .plus_one }}" , add_me );
100+ let output = gtmpl_ng :: template (" The answer is: {{ .plus_one }}" , add_me );
99101 assert_eq! (& output . unwrap (), " The answer is: 43" );
100102}
101103```
@@ -118,7 +120,7 @@ there might be some convenient additions:
118120
119121Enable ` gtmpl_dynamic_template ` in your ` Cargo.toml ` :
120122``` toml
121- [dependencies .gtmpl ]
123+ [dependencies .gtmpl-ng ]
122124version = " 0.7"
123125features = [" gtmpl_dynamic_template" ]
124126
@@ -129,7 +131,7 @@ Now you can have dynamic template names for the `template` action.
129131#### Example
130132
131133``` rust
132- use gtmpl :: {Context , Template };
134+ use gtmpl_ng :: {Context , Template };
133135
134136fn main () {
135137 let mut template = Template :: default ();
@@ -187,6 +189,7 @@ that feel native. [docker] and [helm] ([kubernetes]) use golang templates and
187189it feels more native if tooling around them uses the same.
188190
189191[ gtmpl-rust ] : https://github.com/fiji-flo/gtmpl-rust
192+ [ gtmpl-ng ] : https://github.com/firstdorsal/gtmpl-rust
190193[ Golang text/template ] : https://golang.org/pkg/text/template/
191194[ kubernetes ] : https://kubernetes.io
192195[ helm ] : https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/templates.md
0 commit comments