On Saturday, 17 December 2016 12:26:55 UTC+2, mhh...@gmail.com wrote:
>
> Hi,
>
> I am wondering how i could compile html template against well-known 
> structures 
> to get better performance of it, but keep maintainability and security at 
> high levels.
>
> See this template 
>
> https://github.com/mh-cbon/mdl-go-components/blob/master/mdl/templates/button.tmpl
>
> And this implementation against its well known structure
>
> https://github.com/mh-cbon/mdl-go-components/blob/master/mdl/fast/render.go#L66
>
> My benchmark shows an awesome performance increase
>
> $ go test -bench=.
> BenchmarkRenderWithTemplate-4          30000         56485 ns/op
> BenchmarkRenderWithFast-4            2000000           968 ns/op
> PASS
> ok      command-line-arguments  4.989s
>
>
> But i don t feel like doing it by hands... Possible, but its an hard time 
> of maintenance and production.
>
>
> I hope and would like to have a program that would take a template and a 
> struct in input, 
> and produces a func or struct (whatever) in output.
>
> So I wonder if anyone could provide some tips and hints about automation 
> of such work,
> for instance i don t have any other clues other than getting wetting my 
> feet into the ast tree and playing with go generate.
>

The poc ast approach: https://play.golang.org/p/zn0ZFlVctn
Obviously would need a lot more cases to be fully compliant with 
html/template

+ Egon

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to