Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Make template.Execute write output to a string
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sankar P  
View profile  
 More options May 2 2012, 1:43 pm
From: Sankar P <sankar.curios...@gmail.com>
Date: Wed, 2 May 2012 23:13:49 +0530
Local: Wed, May 2 2012 1:43 pm
Subject: Make template.Execute write output to a string
Hi,

How do I make template.Execute write the generated html to a string
instead of a Writer object ? Is there a StringWriter or some such
class that I can make use of ? If I have to write into some other
writer and then read from it, what writer should I use best for this
scenario ?

Thanks.

--
Sankar P
http://psankar.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sdegu...@8thlight.com  
View profile  
 More options May 2 2012, 1:51 pm
From: sdegu...@8thlight.com
Date: Wed, 2 May 2012 10:51:55 -0700 (PDT)
Local: Wed, May 2 2012 1:51 pm
Subject: Re: Make template.Execute write output to a string

http://golang.org/pkg/bytes/#Buffer and its method
http://golang.org/pkg/bytes/#Buffer.String

-Steven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sankar P  
View profile  
 More options May 2 2012, 2:24 pm
From: Sankar P <sankar.curios...@gmail.com>
Date: Wed, 2 May 2012 23:54:55 +0530
Local: Wed, May 2 2012 2:24 pm
Subject: Re: Make template.Execute write output to a string
Thank you a lot everybody. It works.

For future reference of anyone having the same problem, the code that I've used:

        var doc bytes.Buffer
        t.Execute(&doc, survey)
        s := doc.String()

Thanks.

--
Sankar P
http://psankar.blogspot.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russ Cox  
View profile  
 More options May 2 2012, 2:58 pm
From: Russ Cox <r...@golang.org>
Date: Wed, 2 May 2012 14:58:49 -0400
Local: Wed, May 2 2012 2:58 pm
Subject: Re: [go-nuts] Re: Make template.Execute write output to a string

On Wed, May 2, 2012 at 2:24 PM, Sankar P <sankar.curios...@gmail.com> wrote:
>   var doc bytes.Buffer
>   t.Execute(&doc, survey)
>   s := doc.String()

It will work even better if you check for an error from t.Execute.

Russ


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sankar P  
View profile  
 More options May 2 2012, 3:04 pm
From: Sankar P <sankar.curios...@gmail.com>
Date: Thu, 3 May 2012 00:34:35 +0530
Local: Wed, May 2 2012 3:04 pm
Subject: Re: [go-nuts] Re: Make template.Execute write output to a string

On Thu, May 3, 2012 at 12:28 AM, Russ Cox <r...@golang.org> wrote:
> On Wed, May 2, 2012 at 2:24 PM, Sankar P <sankar.curios...@gmail.com> wrote:
>>   var doc bytes.Buffer
>>   t.Execute(&doc, survey)
>>   s := doc.String()

> It will work even better if you check for an error from t.Execute.

Thanks. I will be careful.

--
Sankar P
http://psankar.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »