Help with Custom ERB Templates

This is a discussion on Help with Custom ERB Templates within the RUBY forums in Programming Languages category; I'm trying to create a custom erb template that allows me to mix MXML and Ruby. I'm having problems coming from the way I wish to implement it. In MXML you need tags which I would like to use Ruby to create. Take note of the following MXML snippet: <mx:Application "xmlns:mx"="http://www.adobe.com/2006/mxml" > blah blah blah </mx:Application> I would like to have an mxml/erb file create that in Ruby by doing something like the following: <% MX::Application.new{|app| app["xmlns:mx"]="http://www.adobe.com/2006/mxml" %> blah blah blah <% } %> In my current solution, ERB runs the Ruby code and generates the tag with the proper ...

Go Back   Application Development Forum > Programming Languages > RUBY

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-28-2008, 12:35 AM
Eric Michael
Guest
 
Default Help with Custom ERB Templates

I'm trying to create a custom erb template that allows me to mix MXML
and Ruby. I'm having problems coming from the way I wish to implement
it.

In MXML you need tags which I would like to use Ruby to create.

Take note of the following MXML snippet:

<mx:Application "xmlns:mx"="http://www.adobe.com/2006/mxml" >
blah blah blah
</mx:Application>


I would like to have an mxml/erb file create that in Ruby by doing
something like the following:

<% MX::Application.new{|app|
app["xmlns:mx"]="http://www.adobe.com/2006/mxml" %>
blah blah blah
<% } %>


In my current solution, ERB runs the Ruby code and generates the tag
with the proper options but displays the non-ruby part afterwards such
as this:

<mx:Application "xmlns:mx"="http://www.adobe.com/2006/mxml" >
</mx:Application>

blah blah blah


Would there be any way to capture the "blah blah blah" as a string and
somehow pass that to the underlying Ruby so it can be told when to
print?

I would really like for the curly-braces to signify the start and end of
a tag.

I suppose the functionality I'm trying to mimic is similar to form_tag
in Rails

<% form_tag '/posts' do -%>
<div><%= submit_tag 'Save' %></div>
<% end -%>

Thanks
--
Posted via http://www.ruby-forum.com/.

Reply With Quote
  #2  
Old 08-28-2008, 01:23 AM
Eric Michael
Guest
 
Default Re: Help with Custom ERB Templates

Nevermind! http://builder.rubyforge.org/ seems to be a good base for
combining this and ERB.
--
Posted via http://www.ruby-forum.com/.

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:52 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.