Il giorno venerdì 18 novembre 2016 21:23:38 UTC+1, Ian Lance Taylor ha 
scritto:
>
> On Fri, Nov 18, 2016 at 11:50 AM, Manlio Perillo 
> <manlio....@gmail.com <javascript:>> wrote: 
> > 
> > I'm trying to implement HTML form support in Go, 
> > Forms are one of the most complex components to implement in a web 
> > application. 
> > 
> > Here is a simple form with only two text field, using bootstrap: 
> > https://gist.github.com/anonymous/5a21a22e6d5fd9d0f745c1700c634b54 
> > 
> > Writing the HTML code by hand is unreasonable, and having the form to be 
> > automatically generated from Go source code is not flexible. 
> > There are a lot of details for the form UI that needs to be specified. 
> > 
> > I would like to have support for macros in html/template. 
> > As an example, something like this: 
> > https://gist.github.com/anonymous/6a5f0165df14677e277d7d2b53294882 
> > 
> > When parsing the macro action {{% func <args> %}}, the verbatim text for 
> > <args> will be passed to fun. 
> > The function func will parse, at template parsing time, the text and 
> will 
> > return the transformed text that will be then processed by parser. 
> > 
> > Is this feasible? 
>
> It shouldn't be necessary to add a programming language to templates, 
> since you already have a programming language to use, namely Go 
> itself.  This doesn't necessarily mean generating HTML in Go--the Go 
> function can simply be a text transformation on its arguments. 
>
>
It's true that I can use raw strings, e.g (not tested).

{{ field "sku" . `<label class="col-xs-2 control-label">SKU</label>
    <input autofocus>
    <help>{{ .Errors.sku }}</help>`
}}

However there are two problems:
1) I need to parse the argument each time the function is called
2) the text returned by the function will not be parsed again by the 
template parser.


Manlio 

-- 
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