Monday, April 16, 2012

Convert ERb into HAML (via rake)

install these gems:

haml-rails
ruby_parser
hpricot


#./lib/tasks/erb2haml.rake
desc "Creates haml files for each of the erb files found under views (skips existing)"
task :erb2haml do
  from_path = File.join(File.dirname(__FILE__), '..', '..', 'app', 'views')
  Dir["#{from_path}/**/*.erb"].each do |file|
    puts file
  # for each .erb file in the path, convert it & output to a .haml file
  output_file = file.gsub(/\.erb$/, '.haml')
  `bundle exec html2haml -ex #{file} #{output_file}` unless File.exist?(output_file)
 end
end

now run rake
and don't forget that its not rake erb2html, its rake erb2haml!

From:
here

PS:
gem 'ruby_parser'
gem 'hpricot'

Sunday, April 15, 2012

set up git for the first use (with rails)

After installing the packages git-core and gitosis:

configure
git config --global user.name "username"
git config --global user.email "user@mail.com"
git config --global core.editor "emacs -w"

run
git init

customize the .gitignore file
examples here

add your project to git
git add . ## from your project folder


to see which files are in the staging area:
git status

to tell Git you want to keep the changes
git commit -m "initial commit"


list of commit messages:
git log


undo changes
git checkout -f ## -f flag to force overwriting the current changes