Hi,

see this play,
https://play.golang.org/p/s-GdewdWz_

In my understanding, 
as the template is empty, 
it is not added to the templates tree, 
i suspect it has something to do with that,
https://golang.org/src/text/template/parse/parse.go?#L243

Maybe a non breakable space like   will do the trick ?

On Wednesday, February 15, 2017 at 5:10:16 PM UTC+1, Manlio Perillo wrote:
>
> Hi.
>
> I have found an unexpected behavior with the html/template package.
> This is a sample program:
> https://play.golang.org/p/Yh7UZJxQOd
>
> It will print:
>
> <!DOCTYPE html>
> <html lang="en">
>   <head>
>     
> <title>Test 2</title>
>
>   </head>
>   <body>
>     <h1>Test</h1>
>   </body>
> </html>
>
>
>
> However, suppose I want to "disable" the "head" template;
> the reasonable solution is to define an empty "head" template in the 
> associated template:
> https://play.golang.org/p/yexg_Hxujq
>
> However this prints:
>
> <!DOCTYPE html>
> <html lang="en">
>   <head>
>     
> <title>Test 1</title>
>
>   </head>
>   <body>
>     <h1>Test</h1>
>   </body>
> </html>
>
>
> instead of the expected:
>
> <!DOCTYPE html>
> <html lang="en">
>   <head>
>     
>   </head>
>   <body>
>     <h1>Test</h1>
>   </body>
> </html>
>
>
> Is this a bug?
>
>
> Thanks
> 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