On Monday, 19 December 2016 13:04:23 UTC+2, [email protected] wrote:
>
> hi, thanks.
>
> tbh, i m not sure i feel like i want to do php-like dev in go.
> I m not even certain that the apparent gain in flexibility and speed of
> development really worth it.
> Guts tell me this is like giving the wrong tools to the wrong worker to do
> the wrong job.
> A front end dev won t really benefit of such powerfull templates, and it
> could probably
> give him way more hard time than benefits, a backend dev does not really
> benefit of such
> intrusion of his code into the presentation layer, he usually is not so
> good in design.
> Also, i don t think it helps to solve the general problem of go with
> templating,
> express similarities but yet avoid duplication, when you develop a backend
> you have hundreds of pages very similar to each other, a table of users or
> a table of blog posts
> its a table after all, except those little differences in the number and
> types of column,
> which go really is not good to manage, because their are totally different
> according to its type model.
> Giving more responsibility and power to the presentation, to me, really
> does not sound to be a way to solve that.
> Recently i worked on a component oriented approach with a clear separation
> of concerns
> between the client and server domains, i found it was a good fit between
> all parameters i identified
> and felt concerned with.
> yet i guess we agree to say its a waste to loose so much machine resource
> with the current implementation of templates, even though,
> and as often with go, there are lots of great and awesome properties in it.
>
Just a note, you can also think of working with a custom DSL, rather than
working with templates or io.Writer directly... e.g:
type Table struct {
Rows []struct{
Cells []ui.Renderer
}
}
func (table *Table) Render(w ui.Writer) {
defer w.Wrap("table")()
for _, row := range table.Rows {
w.Start("tr")
for _, cell := range row.Cells {
w.Start("td")
cell.Render(w)
w.End("td")
}
w.End("tr")
}
}
type CustomLink struct {
Name ui.TextContent
ID ui.ID
Class ui.ClassList
URL ui.URL
Disabled bool
}
func (link *CustomLink) Render(w ui.Writer) {
if !link.Disabled {
defer w.Wrap("a")()
link.URL.Render(w)
} else {
defer w.Wrap("span")()
}
link.ID.Render(w)
link.Class.With("my-custom-link").Render(w)
link.Name.Render(w)
}
+ Egon
> On Monday, December 19, 2016 at 8:11:51 AM UTC+1, Aliaksandr Valialkin
> wrote:
>>
>> Take a look at https://github.com/valyala/quicktemplate . Though it is
>> incompatible with template/html sytax, it provides static template
>> compilation, high performance and go-like syntax.
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.