You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Kelly Ray Jensen <ke...@myrealbox.com> on 2002/01/28 01:21:32 UTC

Rendering problem?

I am currenlty having a problem rendering text that contains Html tags.

In my template I have the following that uses a regular expression to
wrap all of the $words found within $text with the Html tags
(startHighlight and endHighlight).

--------

#set($text = "some sample text")
#set($words = ["some", "text"])  ## String array
#set($startHighlight = "<b>")
#set($endHighlight = "</b>")


## this function returns a String with the $words found in $text
## wrapped with $startHighlight and $endHighlight

$highlighter.hightlight($text, $words, $startHighlight, $endHighlight)

---------

Ideally, this would be rendered as:

"<b>some</b> sample <b>text</b>"


but Velocity is replacing < with &lt; and > with &gt; and returns:

"&lt;b&gt;some&lt;/b&gt; sample &lt;b&gt;text&lt;/b&gt;"


Therefore the browser shows the text surrounded with the tags when I
would like the text to be bold.

Is there a way to tell Velocity to not render < and > as &lt; and &gt;?

thanks,

Kelly





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: anchors a' weigh, me boys

Posted by Sean Burlington <se...@uncertainty.org.uk>.
On Tuesday 19 March 2002 2:39 pm, Bruce Altner wrote:
> How would I point to a named anchor within an html page? For example, if I
> want to direct the browser to display the end of the page
> I'd create an anchor for it:
>
> <a name="bottom"></a>
>
> and call it with the # appended to the url:
> http://myserver.com/foobar.vm#bottom

the link is something the browser uses ..

but foobar.vm is a template used by your servlet internally

try http://myserver.com/<pathtoservlet>#bottom

> I've RTFM'd and tried this within a template by escaping the #,
> e.g.,  http://myserver.com/foobar.vm\#bottom but that doesn't work.
>
> This must be fairly simple. A hint would be appreciated.
>
> Thanks,
> Bruce

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: anchors a' weigh, me boys

Posted by Terry Steichen <te...@net-frame.com>.
For navigation internal to a page, I use this:

<a href=#45> FAQ question </a>,

 which when clicked, goes to this:

<a name=45></a>FAQ Answer.

For external navigation to that location, I include this url in a template:

<a href="$myurl#45">FAQ question</a>

Works just fine.

Regards,

Terry

----- Original Message -----
From: "Bruce Altner" <ba...@hq.nasa.gov>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, March 19, 2002 9:39 AM
Subject: anchors a' weigh, me boys


> How would I point to a named anchor within an html page? For example, if I
> want to direct the browser to display the end of the page
> I'd create an anchor for it:
>
> <a name="bottom"></a>
>
> and call it with the # appended to the url:
> http://myserver.com/foobar.vm#bottom
>
> I've RTFM'd and tried this within a template by escaping the #,
> e.g.,  http://myserver.com/foobar.vm\#bottom but that doesn't work.
>
> This must be fairly simple. A hint would be appreciated.
>
> Thanks,
> Bruce
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: anchors a' weigh, me boys

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/19/02 9:39 AM, "Bruce Altner" <ba...@hq.nasa.gov> wrote:

> How would I point to a named anchor within an html page? For example, if I
> want to direct the browser to display the end of the page
> I'd create an anchor for it:
> 
> <a name="bottom"></a>
> 
> and call it with the # appended to the url:
> http://myserver.com/foobar.vm#bottom
> 
> I've RTFM'd and tried this within a template by escaping the #,
> e.g.,  http://myserver.com/foobar.vm\#bottom but that doesn't work.
> 
> This must be fairly simple. A hint would be appreciated.

Why doesn¹t  http://foo/bar.vm#bottom work?

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


anchors a' weigh, me boys

Posted by Bruce Altner <ba...@hq.nasa.gov>.
How would I point to a named anchor within an html page? For example, if I 
want to direct the browser to display the end of the page
I'd create an anchor for it:

<a name="bottom"></a>

and call it with the # appended to the url: 
http://myserver.com/foobar.vm#bottom

I've RTFM'd and tried this within a template by escaping the #, 
e.g.,  http://myserver.com/foobar.vm\#bottom but that doesn't work.

This must be fairly simple. A hint would be appreciated.

Thanks,
Bruce


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Rendering problem is solved

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/27/02 8:08 PM, "Kelly Ray Jensen" <ke...@myrealbox.com> wrote:

> Geir,
> 
> I just finished testing this problem with the SampleServlet example and
> it works as it should.
> 
> So something in Turbine is causing my problem.


Cool beans.  Post it to turbine then.  They are a friendly lot as well...

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Rendering problem is solved

Posted by Kelly Ray Jensen <ke...@myrealbox.com>.
Geir,

I just finished testing this problem with the SampleServlet example and
it works as it should.

So something in Turbine is causing my problem.

thanks,

Kelly

On Sun, 2002-01-27 at 17:49, Kelly Ray Jensen wrote:
> Geir,
> 
> Thanks for the promp reply.
> 
> I will look at my code again and make sure.
> 
> I am using Turbine, could that be causing the problem?
> 
> I did a test in one of my templates with the following
> 
> #set($text = "<testing>")
> $text
> 
> And I was getting the same problem as below.
> 
> I think it might be the Turbine layer between my application and
> Velocity that is causing the problem.
> 
> I am going to try the example webapp that comes with Velocity and try
> running the same template throught it.
> 
> I'll let you know what happends.
> 
> As everyone else says: Velocity rocks!
> 
> Kelly
> 
> On Sun, 2002-01-27 at 17:36, Geir Magnusson Jr. wrote:
> > On 1/27/02 7:21 PM, "Kelly Ray Jensen" <ke...@myrealbox.com> wrote:
> > 
> > > I am currenlty having a problem rendering text that contains Html tags.
> > > 
> > > In my template I have the following that uses a regular expression to
> > > wrap all of the $words found within $text with the Html tags
> > > (startHighlight and endHighlight).
> > > 
> > > --------
> > > 
> > > #set($text = "some sample text")
> > > #set($words = ["some", "text"])  ## String array
> > > #set($startHighlight = "<b>")
> > > #set($endHighlight = "</b>")
> > > 
> > > 
> > > ## this function returns a String with the $words found in $text
> > > ## wrapped with $startHighlight and $endHighlight
> > > 
> > > $highlighter.hightlight($text, $words, $startHighlight, $endHighlight)
> > > 
> > > ---------
> > > 
> > > Ideally, this would be rendered as:
> > > 
> > > "<b>some</b> sample <b>text</b>"
> > > 
> > > 
> > > but Velocity is replacing < with &lt; and > with &gt; and returns:
> > > 
> > > "&lt;b&gt;some&lt;/b&gt; sample &lt;b&gt;text&lt;/b&gt;"
> > 
> > Velocity is doing no such thing :)
> > 
> > Velocity has no care or clue what your output is, and will never modify your
> > output no matter what you are doing with it.
> > 
> > > 
> > > 
> > > Therefore the browser shows the text surrounded with the tags when I
> > > would like the text to be bold.
> > > 
> > > Is there a way to tell Velocity to not render < and > as &lt; and &gt;?
> > 
> > Can you show us the source code for the highlighter?  Another possibility is
> > that the your application is using reference insertion event handling to
> > escape the <  and >.
> > 
> > 
> > -- 
> > Geir Magnusson Jr.                                     geirm@optonline.net
> > System and Software Consulting
> > "Now what do we do?"
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > 
> > 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Rendering problem?

Posted by Kelly Ray Jensen <ke...@myrealbox.com>.
Geir,

Thanks for the promp reply.

I will look at my code again and make sure.

I am using Turbine, could that be causing the problem?

I did a test in one of my templates with the following

#set($text = "<testing>")
$text

And I was getting the same problem as below.

I think it might be the Turbine layer between my application and
Velocity that is causing the problem.

I am going to try the example webapp that comes with Velocity and try
running the same template throught it.

I'll let you know what happends.

As everyone else says: Velocity rocks!

Kelly

On Sun, 2002-01-27 at 17:36, Geir Magnusson Jr. wrote:
> On 1/27/02 7:21 PM, "Kelly Ray Jensen" <ke...@myrealbox.com> wrote:
> 
> > I am currenlty having a problem rendering text that contains Html tags.
> > 
> > In my template I have the following that uses a regular expression to
> > wrap all of the $words found within $text with the Html tags
> > (startHighlight and endHighlight).
> > 
> > --------
> > 
> > #set($text = "some sample text")
> > #set($words = ["some", "text"])  ## String array
> > #set($startHighlight = "<b>")
> > #set($endHighlight = "</b>")
> > 
> > 
> > ## this function returns a String with the $words found in $text
> > ## wrapped with $startHighlight and $endHighlight
> > 
> > $highlighter.hightlight($text, $words, $startHighlight, $endHighlight)
> > 
> > ---------
> > 
> > Ideally, this would be rendered as:
> > 
> > "<b>some</b> sample <b>text</b>"
> > 
> > 
> > but Velocity is replacing < with &lt; and > with &gt; and returns:
> > 
> > "&lt;b&gt;some&lt;/b&gt; sample &lt;b&gt;text&lt;/b&gt;"
> 
> Velocity is doing no such thing :)
> 
> Velocity has no care or clue what your output is, and will never modify your
> output no matter what you are doing with it.
> 
> > 
> > 
> > Therefore the browser shows the text surrounded with the tags when I
> > would like the text to be bold.
> > 
> > Is there a way to tell Velocity to not render < and > as &lt; and &gt;?
> 
> Can you show us the source code for the highlighter?  Another possibility is
> that the your application is using reference insertion event handling to
> escape the <  and >.
> 
> 
> -- 
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> "Now what do we do?"
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Rendering problem?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/27/02 7:21 PM, "Kelly Ray Jensen" <ke...@myrealbox.com> wrote:

> I am currenlty having a problem rendering text that contains Html tags.
> 
> In my template I have the following that uses a regular expression to
> wrap all of the $words found within $text with the Html tags
> (startHighlight and endHighlight).
> 
> --------
> 
> #set($text = "some sample text")
> #set($words = ["some", "text"])  ## String array
> #set($startHighlight = "<b>")
> #set($endHighlight = "</b>")
> 
> 
> ## this function returns a String with the $words found in $text
> ## wrapped with $startHighlight and $endHighlight
> 
> $highlighter.hightlight($text, $words, $startHighlight, $endHighlight)
> 
> ---------
> 
> Ideally, this would be rendered as:
> 
> "<b>some</b> sample <b>text</b>"
> 
> 
> but Velocity is replacing < with &lt; and > with &gt; and returns:
> 
> "&lt;b&gt;some&lt;/b&gt; sample &lt;b&gt;text&lt;/b&gt;"

Velocity is doing no such thing :)

Velocity has no care or clue what your output is, and will never modify your
output no matter what you are doing with it.

> 
> 
> Therefore the browser shows the text surrounded with the tags when I
> would like the text to be bold.
> 
> Is there a way to tell Velocity to not render < and > as &lt; and &gt;?

Can you show us the source code for the highlighter?  Another possibility is
that the your application is using reference insertion event handling to
escape the <  and >.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"Now what do we do?"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>