Forum: Ruby on Rails is there simpler way to export html within xml

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-07 14:32
Hi,

we're exporting a lot of html code within xml, our current method works
but it's very messy - far from perfect, is there a better way to do
this.

an example of our controller code is

html = html + "<img src="/icon/icon_email.gif"
onclick="javascript:document.getElementById('detail').style.display='none';
document.getElementById('mailform').style.display='inline';
"/>\n"

as you can see we're using the < etc to generate the html required,
so the end result is something like

  <marker html="<img src="/icon/icon_email.gif"
onclick="javascript:document.getElementById('detail').style.display='none';
document.getElementById('mailform').style.display='inline'; "/>...

so within that xml tag you can see a html= option, and within that
option lives all our html.

can anyone suggest a cleaner better way to do this? it would really be
appreciated.

thanks
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-05-07 15:12
(Received via mailing list)
Is it too naive to suggest using the view (or a pseudo view) to generate
the
html using erb?  After all that is what erb is for.
Colin

2009/5/7 Todd Fox <rails-mailing-list@andreas-s.net>
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-07 18:26
how would that work?
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-07 18:28
Todd Fox wrote:
> how would that work?

we need the html in xml (html wrapped inside the xml) for another
application read and then render that html.
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-05-07 22:35
(Received via mailing list)
I am not sure exactly what you would do, I am also not sure exactly what
you
are doing with the xml.  It just seems that an erb view is the ideal
tool
for generating html to be sent to the client.  Is there a lot of xml or
is
it just a wrapper round the html?  If only a wrapper then you could
generate
that 'by hand' so to speak in the erb file also, or in the layout file.

Can anyone else help? I do not really know what I am talking about here.

Colin

2009/5/7 Todd Fox <rails-mailing-list@andreas-s.net>
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-05-07 22:52
(Received via mailing list)
On Thu, May 7, 2009 at 9:28 AM, Todd Fox
<rails-mailing-list@andreas-s.net> wrote:

> we need the html in xml (html wrapped inside the xml) for another
> application read and then render that html.

Does the html need to be an attribute? Or can it just be within an
xml envelope?  IOW, do you control the consuming end of this?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-08 04:34
sorry more info on what it's used for would help, the xml is being read
by google maps api so we can load html code inside the popup bubble.

so yeah we dont really control the consuming end :(
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-05-08 04:39
Todd Fox wrote:
> sorry more info on what it's used for would help, the xml is being read
> by google maps api so we can load html code inside the popup bubble.
>
> so yeah we dont really control the consuming end :(

It seems to me, then, that you have two good options.  Either use ERb
and/or Builder to put the HTML in the XML DOM, or (if the HTML has to be
a string) use a CDATA section.  Don't make your life harder with all
those &entities;.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-08 04:41
thanks Marnen and everyone, do you know of any examples or something i
can have a look at to get my head around it?
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-05-08 04:50
Todd Fox wrote:
> thanks Marnen and everyone, do you know of any examples or something i
> can have a look at to get my head around it?

What's to get your head around?  Just pretend your XML file is an HTML
page, and proceed accordingly with your favorite template language (ERb,
Builder, Haml, Markaby, whatever).  There's no new concept involved.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
Fed972732accd37c4cf1fb56dbfe1405?d=identicon&s=25 Hugh Themm (hughthemm)
on 2009-05-08 18:41
(Received via mailing list)
Way to be appreciative of someone trying to help you.  Good luck with
that.

On May 7, 9:50 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas-
Fed972732accd37c4cf1fb56dbfe1405?d=identicon&s=25 Hugh Themm (hughthemm)
on 2009-05-08 18:42
(Received via mailing list)
My bad MLK.
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2009-05-11 04:57
what are you talking about hugh?! :|

thanks Marnen, we'll try to render xml using an erb this week and let
everyone know if we can do it and how :P
This topic is locked and can not be replied to.