# Builder::XmlMarkup and dashes

**URL:** <https://www.ruby-forum.com/t/builder-xmlmarkup-and-dashes/106482>\
**Category:** Rails\
**Created:** [June 11, 2007, 5:33am UTC](https://www.ruby-forum.com/t/builder-xmlmarkup-and-dashes/106482 "2007-06-11T05:33:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 11, 2007, 5:33am UTC](https://www.ruby-forum.com/t/builder-xmlmarkup-and-dashes/106482/1 "2007-06-11T05:33:46Z")

</div>

Has anyone hacked Builder::XmlMarkup to dasherize underscore tags by  
default? I know I can use tag!, but I’d like to find a way for it to  
translate underscores to dashes automatically. In other words:

xml.department\_manager do  
"fred  
end

#=\> fred

I tried hacking Builder::XmlBase.method\_missing but got myself all  
twisted up!

Thanks.

Steve

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 11, 2007, 8:09am UTC](https://www.ruby-forum.com/t/builder-xmlmarkup-and-dashes/106482/2 "2007-06-11T08:09:56Z")

</div>

On 6/10/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Has anyone hacked Builder::XmlMarkup to dasherize underscore tags by  
> default? I know I can use tag!, but I’d like to find a way for it to  
> translate underscores to dashes automatically. In other words:
> 
> xml.department\_manager do  
> "fred  
> end

xml.tag! ‘department-manger’, ‘fred’

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 12, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/builder-xmlmarkup-and-dashes/106482/3 "2007-06-12T17:44:03Z")

</div>

Right, I know about ‘tag!’ but I was hoping to rig things such that  
XmlMarkup always called ‘dasherize’ on element names.

Steve
