Ticket #25 (assigned enhancement)

Opened 2 years ago

Last modified 2 years ago

rhtml to mab converter

Reported by: joeruby Owned by: why
Priority: major Milestone: 1.0
Component: gem Version: 0.5
Keywords: converter Cc:

Description

Converting rhtml templates to mab is painful! Ow! Dear Lazyweb, I wish there was a converter!

Change History

Changed 2 years ago by why

  • status changed from new to assigned
  • milestone set to 1.0

I guess we'll see...

Changed 2 years ago by tec

Can someone post some good example rhtml please?

Changed 2 years ago by joeruby

Good example rhtml?

Changed 2 years ago by tec

Never mind, try this: http://balloon.hobix.com/mablate

Changed 2 years ago by joeruby

Hey, that works pretty well! :)

I changed a couple lines:

# space before end so it doesn't run together
when /\A<\/\w+?>/ then ' end' # </div>
# catch params that aren't quoted
return ' ' + attrs.scan(/(\w+?)="?([^"]+)"?/).map { |(k, v)| "%p=>'%s'" % [k.to_sym, v] }.join(', ')

Only problems I see right now is that single params (like 'nowrap') don't get output, and methods like start_form_tag get wrapped in text().

Changed 2 years ago by joeruby

Oh, I also removed the \n, as it didn't seem to be needed and was breaking lines unnecessarily:

when /\A<%=(.+?)%>/m then "text(#{$1.strip})"
Note: See TracTickets for help on using tickets.