I
I
IllusionTurtle2015-10-26 16:09:16
go
IllusionTurtle, 2015-10-26 16:09:16

Are there alternative packages for html templates (I wrote my own)?

I don't like GO's proposed approach to html templates - the biggest inconvenience is the difference in syntax, which is very poor in templates.
When the project is small, everything is beautiful and clear, BUT when the project grows, and for example, many variables need to be passed to the template, it becomes difficult to control this, since the same template can be called by different controllers ...
I don’t like pipelines, I don’t like that you have to write your own functions for the simplest conditions, such as more, less, it.d. it's all already in GO itself, why can't you write in the template: {{if int1 > int2}}one{{else}}two{{end}} ???
or am I doing something wrong?
A long search led me to templating erb type for example - https://github.com/benbjohnson/ego- everything suits me here except for declaring the code through <%%> - even if the go developers offer curly braces, why not use them - IMHO: <> - for tags, {{}} - for logic - much more readable
, so it was decided to write your own bike for this task - https://github.com/sg3des/gotemplator - this is more of a sketch than a complete solution so far!
The disadvantage of this approach is that the template has to be generated in go code before starting the
Question 3 project:
1) if the standard approach is actually convenient, but I'm wrong, tell me which way to dig, but rather an example of where it is implemented CONVENIENTLY.
2) Recommend good template engines with GO syntax.
3) rate my package.
Thanks

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Kirill, 2015-10-26
@IllusionTurtle

Try Pongo2 https://github.com/flosch/pongo2

V
v- death, 2015-10-26
@vGrabko99

Did you decide to transfer all the charms of php shit code to golang?!

A
Alexander Taratin, 2015-10-26
@Taraflex

why not use them - IMHO: <> - for tags, {{}} - for logic - much more readable

From your own README
{{for key,val := range data { }} //<- кучка скобок в одном месте
     <div><b>{{=key}}</b>:<i>{{=val}}</i></div>
{{ } }} //<- еще большая кучка скобок в одном месте

It's not that obvious.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question