From 1a9156c01046fc68b02ba7fab4422a40cc13605d Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 9 Aug 2009 21:33:48 -0700 Subject: [PATCH] [Extensions] Compass extensions can now deliver html into a compass project which can be authored in haml if they prefer. --- .../templates/project/welcome.html.haml | 12 ++++++++++++ lib/compass/installers/base.rb | 19 +++++++++++++++++++ lib/compass/installers/manifest.rb | 1 + lib/compass/installers/rails.rb | 4 ++++ 4 files changed, 36 insertions(+) create mode 100644 frameworks/blueprint/templates/project/welcome.html.haml diff --git a/frameworks/blueprint/templates/project/welcome.html.haml b/frameworks/blueprint/templates/project/welcome.html.haml new file mode 100644 index 00000000..ed7c989d --- /dev/null +++ b/frameworks/blueprint/templates/project/welcome.html.haml @@ -0,0 +1,12 @@ +!!! Transition +/ Feel free to delete this, it's just here to act as an example +%html(xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en") + %head + %title Welcome to Compass & Blueprint + %link(rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen, projection") + %link(href="stylesheets/print.css" media="print" rel="stylesheet" type="text/css") + /[if lt IE 8] + %link(href="stylesheets/ie.css" media="screen, projection" rel="stylesheet" type="text/css") + %body#welcome.bp + #container + %h1 Welcome to Compass! \ No newline at end of file diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index fb1e26c3..eab60e54 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -125,6 +125,25 @@ module Compass "#{pattern_name_as_dir}#{to}" end + installer :html do |to| + "#{pattern_name_as_dir}#{to}" + end + + alias install_html_without_haml install_html + def install_html(from, to, options) + if to =~ /\.haml$/ + require 'haml' + html = Haml::Engine.new(File.read(templatize(from)), :filename => templatize(from)).render + to = to[0..-(".haml".length+1)] + if respond_to?(:install_location_for_html) + to = install_location_for_html(to, options) + end + write_file(targetize(to), html, options) + else + install_html_without_haml(from, to, options) + end + end + # returns an absolute path given a path relative to the current installation target. # Paths can use unix style "/" and will be corrected for the current platform. def targetize(path) diff --git a/lib/compass/installers/manifest.rb b/lib/compass/installers/manifest.rb index bd5d9a34..7c780f40 100644 --- a/lib/compass/installers/manifest.rb +++ b/lib/compass/installers/manifest.rb @@ -34,6 +34,7 @@ module Compass type :image type :javascript type :file + type :html # Enumerates over the manifest files def each diff --git a/lib/compass/installers/rails.rb b/lib/compass/installers/rails.rb index 9f2a3e36..f2b7df40 100644 --- a/lib/compass/installers/rails.rb +++ b/lib/compass/installers/rails.rb @@ -65,6 +65,10 @@ NEXTSTEPS "/stylesheets" end + def install_location_for_html(to, options) + separate("public/#{pattern_name_as_dir}#{to}") + end + def prompt_sass_dir recommended_location = separate('app/stylesheets') default_location = separate('public/stylesheets/sass')