Home
TeamSite
getting line breaks using textarea
christinelewis
I need to create output that will be used as plain text. I am usint <textarea> for the input but any line breaks that are put in are being lost. Is there a way to keep line breaks? For example:
Line one.
Line Two.
Line Three.
Becomes:
Line One. Line Two. Line Three.
I've seen a couple of posts about similar issues but so far nothing that address this exactly.
Thanks!
Find more posts tagged with
Comments
Migrateduser
Are you outputting to an HTML file and want the line breaks there, or do you want to preserve the line breaks within the DCR? I'm not clear on what you're looking to do.
Dave
Dwayne
If you're truely generating to a plain text file (*.txt) rather than an HTML file, then the line breaks should remain, unless you're filtering them out in your presentation template. Actually, even if you are generating HTML, it should still be preserving the line breaks in the generated page. It's just that they won't be visible to the user, since they'll just be treated as whitespace, and basically be ignored.
Can you zip up the presentation template, a DCR and a page generated by that DCR and attach them? That might help with tracking it down.
--
Current project: TS 5.5.2/6.1 W2K
christinelewis
Thanks for comments, here is a bit more detail.
I have one DCR that I am using to capture content for emails. I'm using visual format editor to capture what will be an HTML email and textarea to capture what will be for the plain text emails. These both go through one presnetation template which is creating two HTML files (can I do one HTML and one TXT?), naming them and attaching meta data to each. This is my first attempt at something like this so if there is a better/more effecient way, please do tell...
The goal is to preserve the line breaks in the HTML file that is being generated from the textarea content.
Here is the bit of my presentation template that is doing the HTML files:
<!-- generate HTML email -->
<iw_value name='dcr.email.html_body.value'/>
<!-- generate plain text email -->
<iw_ostream file_val='linkPath'>
<iw_value name='dcr.email.plain_text.value'/>
</iw_ostream>
Not sure if the DCT info is usefule but here are those bits:
<symbol name="html_body">
<container combination="and" hide-name="f" name="html_body">
<label>HTML</label>
<item name="value">
<textarea external-editor="visualformat" external-editor-config="VFiSharesNetconfig.xml" required="t" cols="55" rows="25" wrap="virtual"/>
</item>
</container>
</symbol>
<symbol name="plain_text">
<container combination="and" hide-name="f" name="plain_text">
<label>Plain Text</label>
<item name="value">
<textarea cols="55" required="f" rows="15" rtf="f" wrap="off"/>
</item>
</container>
</symbol>
Let me know if there is additional info that would be helpful. Thanks!!!
Dwayne
These both go through one presnetation template which is creating two HTML files (can I do one HTML and one TXT?)
I suspect that if you look at the source for your HTML, you'll find that the line breaks are actually there. The problem is that the web browser is discarding them when it views it, because, in HTML, line breaks are treated exactly the same as any other white space.
If you're going to be including this an a text/plain section of a MIME-encoded email, then it shouldn't matter - the line breaks should be there. If, however, you need to view these files in a web browser, you could wrap your text output inside
<pre> </pre>
tags, which will preserve your formatting.
As far as generating one HTML and one TXT goes - I assume that you're generating the files using the
<iw_ostream>
tag. You can name the output file anything you like - it doesn't have to match the extension named in
templating.cfg
.
--
Current project: TS 5.5.2/6.1 W2K
Migrateduser
Yes, you can create the HTML and TXT versions through one presentation template.
I think it's actually putting in the line breaks, but in the HTML version, it's not rendering because you either need to replace the new line characters (\n) with the HTML equivalent (either <br> or <p>) OR you can enclose your HTML output with a <pre> </pre> tags.
Dave