How to output things like  

41 views
Skip to first unread message

johan

unread,
Jul 6, 2011, 3:06:17 AM7/6/11
to WebSharper
Hi!

I'm pulling my hair out trying to output a non-breaking space. The
following does not create the result I want:

P [Text "one two"]

...since the '&' gets HTML-encoded into &

Any ideas?

Thanks,

J

Joel Björnson

unread,
Jul 6, 2011, 4:49:19 AM7/6/11
to websh...@googlegroups.com
Hi,
as you pointed out, text nodes are escaped before inserted. There is
currently no combinator for easily inserting raw text strings so
you'll have to define your own. Here is an example using jQuery:

open IntelliFactory.WebSharper.JQuery

[<JavaScript>]
let (-!) (elem: Element) (text: string) =
JQuery.Of(elem.Body).Html(text).Ignore
elem

Your example can now written as:

P [] -! "one&nbsp;two"


Joel

johan

unread,
Jul 6, 2011, 4:57:44 PM7/6/11
to WebSharper
Ah, that should do it!

Tack,

J
Reply all
Reply to author
Forward
0 new messages