Skip to content

Commit

Permalink
[Extensions] Make it possible for extensions to create empty director…
Browse files Browse the repository at this point in the history
…ies. Closes CompassGH-173.
  • Loading branch information
chriseppstein committed Jul 24, 2010
1 parent dafbf93 commit 755b9a3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
12 changes: 11 additions & 1 deletion doc-src/content/tutorials/extensions.markdown
Expand Up @@ -165,13 +165,14 @@ You may also see some real manifest files here:

### Manifest Declarations

There are five kinds of manifest declarations:
There are six kinds of manifest declarations:

1. `stylesheet` - Declares a sass file.
2. `image` - Declares an image.
3. `javascript` - Declares a javascript file.
4. `html` - Declares an html file.
5. `file` - Declares a random file.
6. `directory` - Declares a directory should be created.

All declarations take the path to the file as their first argument. Note that the
normal slash `/` can and should be used in a manifest. Compass will take care of
Expand All @@ -196,6 +197,15 @@ Stylesheet options:
* `:condition` - this is used to hint the user that a conditional comment should be
used to import the stylesheet with the given condition.

Directory options:

* `:within` - where the directory should be created. If omitted, the directory
will be relative to the project directory. Can be one of: the following
* `sass_dir`
* `javascripts_dir`
* `fonts_dir`
* `images_dir`

HTML files:

You can provide html as haml or as plain html. If you provide haml, the haml will be
Expand Down
13 changes: 13 additions & 0 deletions lib/compass/installers/base.rb
Expand Up @@ -116,6 +116,19 @@ def install_stylesheet(from, to, options)
"#{pattern_name_as_dir}#{to}"
end

def install_directory(from, to, options)
d = if within = options[:within]
if respond_to?(within)
targetize("#{send(within)}/#{to}")
else
raise Compass::Error, "Unrecognized location: #{within}"
end
else
targetize(to)
end
directory d
end

alias install_html_without_haml install_html
def install_html(from, to, options)
if to =~ /\.haml$/
Expand Down
1 change: 1 addition & 0 deletions lib/compass/installers/manifest.rb
Expand Up @@ -40,6 +40,7 @@ def each_#{t}
type :font
type :file
type :html
type :directory

def help(value = nil)
if value
Expand Down
8 changes: 5 additions & 3 deletions lib/compass/installers/manifest_installer.rb
Expand Up @@ -17,9 +17,11 @@ def manifest_file
# Initializes the project to work with compass
def init
dirs = manifest.map do |entry|
loc = send("install_location_for_#{entry.type}", entry.to, entry.options)
File.dirname(loc)
end
unless entry.type == :directory
loc = send("install_location_for_#{entry.type}", entry.to, entry.options)
File.dirname(loc)
end
end.compact

if manifest.has_stylesheet?
dirs << sass_dir
Expand Down

0 comments on commit 755b9a3

Please sign in to comment.