[racket] How to not escape html entities in xexpr->string ?
Oh, I see. You might also be able to use something like:
(string->xexpr "<tag>...</tag>")
to turn the XML into a xexpr, and then include it into the template.
On Sat, 9 Jun 2012 22:05:39 +0800, 安龙 <aisk1988 at gmail.com> wrote:
> Thx for answer, but the situation is I must insert some html slices from
> other place to the xexpr.
>
> 2012/6/9 Michael Wilber <mwilber at uccs.edu>
>
> > Strings aren't safe in XML by definition.
> >
> > Are you thinking of this, but with xexprs?
> > (define title "<h1>Hello world</h1>")
> >
> > (string-append "<html><body>"
> > title
> > "</body></html>")
> >
> > You can create templates by joining parts of other templates using the
> > backquote, like this:
> >
> > (define some-title '(h1 "Hello world"))
> >
> > (xexpr/response
> > `(html
> > (head (title "Test page"))
> > (body ,some-title)))
> >
> > Keeping the structure of each part explicit allows xexpr/response to do
> > the right thing. It will escape what needs to be escaped and leave the
> > tags alone.
> >
> > On Sat, 9 Jun 2012 12:29:36 +0800, 安龙 <aisk1988 at gmail.com> wrote:
> > > Hi all,
> > > I use xexpr to write template, but i find "xexpr/response" will
> > escape
> > > html entities like "<" to < . xexpr->string do this thing also, so how
> > > to mark some strings are "safe" in expr?
> > >
> > > Best wishes
> > >
> > >
> > > --
> > > aisk
> > Non-text part: text/html
> > > ____________________
> > > Racket Users list:
> > > http://lists.racket-lang.org/users
> >
>
>
>
> --
> 安龙
Non-text part: text/html