Change .rhtml => .erb

Posted by John
on Tuesday, 18 December 2007

In a bout of syntactical changes, Rails 2.0 harks the end of the .rhtml file extension; to be replaced with .erb

To change all your existing .rhtml files to .html.erb, run:

for f in $(find . -name '*.rhtml') ; do c=$(dirname $f)/$(basename $f .rhtml).html.erb ; hg mv $f $c ; done

The .html is to help with working out what contents are in the file, as it could in theory have both.

  • .html.erb = html
  • .css.erb = css

p.s. the script above doesn't do .css.erb, that's something you'll have to decide whether to use.

Thanks to Duncan Ponting for this.

HAML, SASS, and IE Conditionals

Posted by John
on Thursday, 26 July 2007

This stuff is really cool… after doing some more research into writing rails code the right way I managed to bump into a rocking thing called HAML via the Railscasts & Peepcode video tutorial sites.

Introduction

Before I continue, may I say thank you to Geoffery Grosenbach for his TopFunky Ruby on Rails Field Guide, an excellent piece of work and has really helped to answer the questions that some books leave un-checked; well done!

You can get this by purchasing one of Geoffrey’s Peepcode videos at link also suggest you watch his blog at Nuby on Rails

HAML, SASS & IE Conditionals

Now if you’ve got your feet wet with Rails development you’ll have coded .RHTML files and know what they’re about, they’re programmatically generated content pages the user sees, along with the div tags, css and generated Javascript. But like everything else, .NET, ASP, etc they don’t give you some help when coding the opening & closing tags.

Thankfully HAML is at hand, it’s a plugin to Ruby which basically allows you to create the generated view pages and essentially not have to worry about closing any tags you’ve left open or remembering how to write P-aragraph tags correctly, try it out and you’ll be amazed at how fast and small you’re development time gets.

install via…
bq. ./script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable

Now along with this there’s SASS which does what HAML does to CSS generation, damn cool!

Along with this there’s IE Conditionals, which are essentially pieces of code you can put in your .RHTML / .HAML files so to do things particular to IE browser users.

IE Conditionals

Have a look, HAML also supports these quick & easy link

With all the cool new things and well thought out processes, you know, things done right, Ruby on Rails really shines as something not to miss out on, and at the very least may force a change in other languages much like Firefox did to IE.

…but in a good way, ;-)