Skip to content

Instantly share code, notes, and snippets.

@mnutt
Created April 17, 2009 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnutt/97210 to your computer and use it in GitHub Desktop.
Save mnutt/97210 to your computer and use it in GitHub Desktop.
# .git/hooks/pre-commit:
#!/usr/bin/env sh
rake static:generate
git add static
# Rake task:
require 'rake'
ROOT = File.join(File.dirname(__FILE__))
namespace :static do
task :generate do
layout = `cat #{ROOT}/views/layout.haml | sed s/yield/\\\"CUTHERE\\\"/ | haml`
Dir["#{ROOT}/views/*.haml"].reject {|v| v =~ /layout.haml/ }.each do |view|
processed_page = layout.sub("CUTHERE", `haml #{view}`)
static_file_name = view.sub("views", "static").sub("haml", "htm")
File.open(static_file_name, "w") do |f|
f.write processed_page
end
end
end
end
# mnutt@mnutt-mac ~/code/prototype (master) $ tree
#.
#|-- README
#|-- Rakefile
#|-- controller.rb
#|-- prototype
#| |-- css
#| | `-- global.css
#| |-- img
#| | |-- connection_bars.png
#| | |-- file_audio.png
#| | |-- file_document.png
#| | |-- file_image.png
#| | |-- file_video.png
#| | |-- header_footer_bg.png
#| | |-- search_button.png
#| | |-- search_dropdown_bg.png
#| | |-- search_input_bg.png
#| | |-- similar_arrow.png
#| | |-- sr_list_buttons.png
#| | `-- toolbar_sprite.png
#| |-- index.html
#| `-- js
#| |-- jquery.js
#| `-- system.js
#|-- static
#| `-- index.htm
#`-- views
# |-- index.haml
# `-- layout.haml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment