Re: confused about html escaping

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Monday, April 23, 2012, 9:32:54 PM, S Ahmed wrote:

> it isn't failing, it is just for some reason eating up any text that has 'bad characters'.

FreeMarker doesn't remove bad characters. Either it leaves them as is,
or it escapes them as &lt; and such (unless you are using something
like <#escape x as ''>, but why would you). So look into to this
closer. Are you 100% sure the part with the bad characters aren't
present in the output if you look at the output as raw text (but not
with something overly smart like FireBug, that parses the HTML and
then shows a new fake HTML source), not rendered in the browser?

Regarding <#escape ...>...<#nested>...</#escape>. That #escape call
doesn't affect the template part that you invoke with #nested. That's
because, by design, #escape has only effect on the interpolations that
are inside in it in the source code. It has no runtime effect. (This
is explained here: http://freemarker.org/docs/ref_directive_escape.html)

-- 
Best regards,
 Daniel Dekany

> For example, if line property has the text:
>
> "this is a sentence < this part does't show up>"
>
> My webpage will just show the text "this is a sentence "
>
> My on the server side, in my breakpoint, I can see that the entire sentence is there.
>
> On Mon, Apr 23, 2012 at 2:28 PM, Denis Bredelet <[email protected]> wrote:
>
>> My page is wrapped in a module that does has html escaping:
>>
>> <#escape x as x?html>
>> ..
>>
>> <#nested>
>> ..
>>
>> </#escape>
>>
>> Then my nested section is outputing the values of a collection like this:
>>
>> <pre>
>>                     <#list someCollection as doc>
>>                         <div class="line">${doc.line}</div>
>
> Do you really have a collection "someCollection", for which each
> element has a "line" property, in your datamodel?
>
> FreeMarker does not normally fail silently so any error message would help here.
>
> -- Denis.
>
>>                     </#list>
>> </pre>
>>
>> Now the value of line is like "< some text here>"
>>
>> But on my page, it is showing up as blank. Looking at the actual
>> rendered html it shows blank also. When I set a breakpoint in my
>> code, I can see that the collection has the value "< some text here
>> >" for the item in the collection 'someCollection'.
>>
>> I tried removing the <#escape x as x?html> also and nothing
>> changed, still don't see the row.
>>
>> I just want to safely display this information like this in the
>> html: &lt; some text here &gt;
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> For Developers, A Lot Can Happen In A Second.
>> Boundary is the first to Know...and Tell You.
>> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
>> http://p.sf.net/sfu/Boundary-d2dvs2
>> _______________________________________________
>> FreeMarker-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.