[Extensions] Compass extensions can now deliver html into a compass project which can be authored in haml if they prefer.

This commit is contained in:
Chris Eppstein 2009-08-09 21:33:48 -07:00
parent f8834532ce
commit 1a9156c010
4 changed files with 36 additions and 0 deletions

View File

@ -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!

View File

@ -125,6 +125,25 @@ module Compass
"#{pattern_name_as_dir}#{to}" "#{pattern_name_as_dir}#{to}"
end 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. # 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. # Paths can use unix style "/" and will be corrected for the current platform.
def targetize(path) def targetize(path)

View File

@ -34,6 +34,7 @@ module Compass
type :image type :image
type :javascript type :javascript
type :file type :file
type :html
# Enumerates over the manifest files # Enumerates over the manifest files
def each def each

View File

@ -65,6 +65,10 @@ NEXTSTEPS
"/stylesheets" "/stylesheets"
end end
def install_location_for_html(to, options)
separate("public/#{pattern_name_as_dir}#{to}")
end
def prompt_sass_dir def prompt_sass_dir
recommended_location = separate('app/stylesheets') recommended_location = separate('app/stylesheets')
default_location = separate('public/stylesheets/sass') default_location = separate('public/stylesheets/sass')