Re: Template parser eating newlines; any way to avoid this?

Malcolm Edgar <[email protected]> Fri, 17 Jan 2003 07:46:51 +1100
Newsgroups gmane.comp.java.tapestry.devel
Message-ID <[email protected]>
Hi Oliver,

my understanding of HTML is that a newline character is treaded like a 
space and
additional white space is not significant, so your code should render as:

John Smith [email protected]

If I need additional whitespace I tend to use: &nbsp; and <br/> for line 
breaks.

regards Malcolm

At 06:41 PM 15/01/2003 +0100, [email protected] wrote:
>Our webapp contains some email-forms (contact, feedback, etc.).
>For each of these email-types we have templates which will
>be filled with some user specific data before the email is send.
>
>I use tapestry to read, parse and fill-in data into the templates.
>When the email-template is rendered i extract the rendered output
>and send it as the body of an email.
>
>My problem is, that the tapestry template parser is eating leading and
>trailing
>whitespace and newline that surround tapestry-components.
>
>For example, the template
>----------------------
><span jwcid="name"/>
>
><span jwcid="email"/>
>---------------------
>
>will be rendered to
>---------------------
>John [email protected]
>---------------------
>
>Is there a way to avoid this behaviour?
>
>For the curious, here's the code i use to render the templates:
>----------------------------------------
>     public String renderAndGetContent() throws RequestCycleException {
>
>         IEngine engine = getRequestCycle().getEngine();
>         RequestContext reqcontext = getRequestCycle().getRequestContext();
>         IMonitor monitor = getRequestCycle().getMonitor();
>         RequestCycle cycle = new RequestCycle(engine, reqcontext, monitor);
>         ByteArrayOutputStream out = new ByteArrayOutputStream();
>         IMarkupWriter writer = new HTMLWriter("text/plain", out);
>         cycle.setPage(this);
>         cycle.renderPage(writer);
>         writer.flush();
>         return out.toString();
>     }
>
>This is called e.g. in a form-submit-listener
>
>        EmailFeedbackTemplatep = (EmailFeedbackTemplate)
>cycle.getPage("EmailFeedbackTemplate");
>        .... // set some properties
>        String body = p.renderAndGetContent();
>        // send email
>-----------------------------------------
>
>Thanks for your help,
>
>Oliver
>
>
>
>
>
>-------------------------------------------------------
>This SF.NET email is sponsored by: A Thawte Code Signing Certificate
>is essential in establishing user confidence by providing assurance of
>authenticity and code integrity. Download our Free Code Signing guide:
>http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en
>_______________________________________________
>Tapestry-developer mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/tapestry-developer



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache 
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en