forked from metaskills/less-rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import preprocessor so @import'ed less files are automatic asset depe…
…ndencies. Fixes metaskills#3.
- Loading branch information
1 parent
442b7d4
commit b247f24
Showing
6 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Less | ||
module Rails | ||
class ImportProcessor < Tilt::Template | ||
|
||
IMPORT_SCANNER = /@import\s*['"]([^'"]+)['"]\s*;/.freeze | ||
|
||
def prepare | ||
end | ||
|
||
def evaluate(context, locals, &block) | ||
import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq | ||
import_paths.each do |path| | ||
asset = context.environment[path] | ||
if asset && asset.pathname.to_s.ends_with?('.less') | ||
context.depend_on_asset(asset.pathname) | ||
end | ||
end | ||
data | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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