Thursday, October 24, 2013

Magical path/url helpers

Magical path/url helpers

Where do those magical path/url helpers pull the values together? I found this interesting.

b /Users/davidvezzani/.rvm/gems/ruby-1.9.3-p194@rails328/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:222

HAML to ERB

Convert Haml to ERB

http://makandracards.com/makandra/544-convert-haml-to-erb

There are plenty of tools for converting from ERB to HAML. I'm not ready to drink the kool aid, even though HAML has been around forever and there seems to be a great following.

script/plugin install http://github.com/cgoddard/haml2erb.git

hamls = Dir["app/views/**/*.haml"] - ['app/views/layouts/screen.html.haml'];
hamls.each do |haml| 
  puts haml
  erb = haml.sub(/\.haml$/, '.erb')
  File.open(erb, 'w') do |file| 
    file.write Haml2Erb.convert(File.read(haml)) 
  end
end

Friday, October 18, 2013

Automatically generate ERB

There are plenty of hits on how you can tell Rails to automatically generate HAML, but I still love using ERB. Taking a guess with the pattern for automatically generating HAML, it appears I got it right.

Somehow, Comfortable Mexican Sofa buries the setting for automatically generating HAML in some dark corner of it's codebase. Setting the preference in config/application.rb takes precedence, thank goodness.

    config.generators do |g|
       # g.template_engine :haml
       g.template_engine :erb
    end