Created
January 6, 2012 07:42
-
-
Save okkez/1569552 to your computer and use it in GitHub Desktop.
A sample of generating HTML with haml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'haml' | |
require 'rake/clean' | |
SRC = FileList["haml/*.haml"].exclude("haml/layout.haml") | |
TARGET = SRC.ext(".html") | |
CLEAN.push(TARGET.sub("haml/", "html/")) | |
rule ".html" => ".haml" do |t| | |
engine = Haml::Engine.new(File.read('haml/layout.haml')) | |
scope = Object.new | |
output = engine.render(scope, :title => t.source.ext("")){ | |
e = Haml::Engine.new(File.read(t.source)) | |
e.render(scope) | |
} | |
File.open(t.name, "w+") do |file| | |
file.puts output | |
end | |
end | |
desc "generate html files" | |
task :html => TARGET do |t| | |
mkdir_p "html" | |
mv t.prerequisites, "html/" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment