# Static HTML in XML Builder or otherwise; With Dynamic Sectio

**URL:** <https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589>\
**Category:** Rails\
**Created:** [March 4, 2010, 11:04pm UTC](https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589 "2010-03-04T23:04:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [March 4, 2010, 11:04pm UTC](https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589/1 "2010-03-04T23:04:02Z")

</div>

Best way to display HTML file as text or xml where some parts are  
dynamic?

So we have a Static HTML file and some portions will be dynamically  
changed.

The Idea is to render as text or xml simply.

If we read this Template HTML file and Dynamically change it, where  
should we store this HTML file?

If we create using XML Builder, would static HTML Part still be needed  
to be coded using Ruby? How can I put Static HTML part in XML Builder?

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [March 5, 2010, 12:24am UTC](https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589/2 "2010-03-05T00:24:25Z")

</div>

Smart RoR wrote:

> Best way to display HTML file as text or xml where some parts are  
> dynamic?
> 
> So we have a Static HTML file and some portions will be dynamically  
> changed.
> 
> The Idea is to render as text or xml simply.
> 
> If we read this Template HTML file and Dynamically change it, where  
> should we store this HTML file?
> 
> If we create using XML Builder, would static HTML Part still be needed  
> to be coded using Ruby? How can I put Static HTML part in XML Builder?

Anyone?

I am thinking to just use XML Builder for HTML here, as static part is  
very less…

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [March 7, 2010, 6:50am UTC](https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589/3 "2010-03-07T06:50:36Z")

</div>

Smart RoR wrote:

> Best way to display HTML file as text or xml where some parts are  
> dynamic?

I really don’t understand what you’re trying to do there. How is what  
you are describing any different than standard ERB templates. They are  
static HTML with some dynamic parts.

> So we have a Static HTML file and some portions will be dynamically  
> changed.

Again isn’t that what ERB is?

> The Idea is to render as text or xml simply.

Both HTML and XML are just text anyway.

> If we read this Template HTML file and Dynamically change it, where  
> should we store this HTML file?

I’d store them in app/views where all the other HTML templates are  
stored. With the dynamic parts rendered with ERB.

> If we create using XML Builder, would static HTML Part still be needed  
> to be coded using Ruby? How can I put Static HTML part in XML Builder?

I can see no need for any of this. Just put the static HTML inside a  
view template and render the dynamic parts with ERB (or HAML if that’s  
what you might prefer).

---

<div class="post-metadata">

**Author:** ![smarter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9fc29f/32.png) [@smarter](https://www.ruby-forum.com/u/smarter)\
**Post date:** [March 7, 2010, 8:01am UTC](https://www.ruby-forum.com/t/static-html-in-xml-builder-or-otherwise-with-dynamic-sectio/184589/4 "2010-03-07T08:01:24Z")

</div>

Robert W. wrote:

> Smart RoR wrote:
> 
> > Best way to display HTML file as text or xml where some parts are  
> > dynamic?
> 
> I really don’t understand what you’re trying to do there. How is what  
> you are describing any different than standard ERB templates. They are  
> static HTML with some dynamic parts.
> 
> > So we have a Static HTML file and some portions will be dynamically  
> > changed.
> 
> Again isn’t that what ERB is?
> 
> > The Idea is to render as text or xml simply.
> 
> Both HTML and XML are just text anyway.
> 
> > If we read this Template HTML file and Dynamically change it, where  
> > should we store this HTML file?
> 
> I’d store them in app/views where all the other HTML templates are  
> stored. With the dynamic parts rendered with ERB.
> 
> > If we create using XML Builder, would static HTML Part still be needed  
> > to be coded using Ruby? How can I put Static HTML part in XML Builder?
> 
> I can see no need for any of this. Just put the static HTML inside a  
> view template and render the dynamic parts with ERB (or HAML if that’s  
> what you might prefer).

Thanks. You are right.

This was part of direct pure AJAX JS call. Still I also think it can  
still interpret as text whether we output from erb or xml builder.
