grunt-include-source
Advanced tools
Comparing version
{ | ||
"name": "grunt-include-source", | ||
"description": "Include your sources into your HTML files automatically.", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/jwvdiermen/grunt-include-source", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -51,6 +51,6 @@ # grunt-include-source | ||
The base URL to use for included files in the final result. | ||
For example, setting `baseUrl` to `public` will result in files being included from `public/path/to/your/file`. | ||
For example, setting `baseUrl` to `public/` will result in files being included from `public/path/to/your/file`. | ||
### Include syntax | ||
Currently supported: `html`, `scss` | ||
Currently supported: `html`, `scss` and `less` | ||
@@ -60,3 +60,3 @@ #### HTML syntax | ||
#### SCSS syntax | ||
#### SCSS and LESS syntax | ||
`// include: options_go_here_as_json` | ||
@@ -66,3 +66,3 @@ | ||
The type of files that are being included. | ||
Currently supported: `html`, `css`, `scss` | ||
Currently supported: `html`, `css`, `scss`, `less` | ||
@@ -105,3 +105,3 @@ #### include.bower | ||
basePath: 'app', | ||
includePath: 'public' | ||
includePath: 'public/' | ||
}, | ||
@@ -108,0 +108,0 @@ myTarget: { |
@@ -39,20 +39,22 @@ /* | ||
// Parses input SASS. | ||
var parseSass = function(source) { | ||
var re = /\/\/\s+include:\s+(.*)/gi, | ||
matches, | ||
results = []; | ||
var parseSassOrLess = function(name) { | ||
return function(source) { | ||
var re = /\/\/\s+include:\s+(.*)/gi, | ||
matches, | ||
results = []; | ||
grunt.log.debug('Parsing SASS...'); | ||
while ((matches = re.exec(source)) !== null) { | ||
if (matches.length <= 1) continue; | ||
grunt.log.debug('Got match, options are { ' + matches[1] + ' }.'); | ||
var optionsObj = JSON.parse("{" + matches[1] + "}"); | ||
results.push({ | ||
start: matches.index, | ||
end: matches.index + matches[0].length - 1, | ||
options: optionsObj | ||
}); | ||
} | ||
grunt.log.debug('Parsing ' + name + '...'); | ||
while ((matches = re.exec(source)) !== null) { | ||
if (matches.length <= 1) continue; | ||
grunt.log.debug('Got match, options are { ' + matches[1] + ' }.'); | ||
var optionsObj = JSON.parse("{" + matches[1] + "}"); | ||
results.push({ | ||
start: matches.index, | ||
end: matches.index + matches[0].length - 1, | ||
options: optionsObj | ||
}); | ||
} | ||
return results; | ||
return results; | ||
}; | ||
}; | ||
@@ -62,3 +64,4 @@ | ||
'html': parseHtml, | ||
'scss': parseSass | ||
'scss': parseSassOrLess('SASS'), | ||
'less': parseSassOrLess('LESS') | ||
}; | ||
@@ -76,2 +79,7 @@ | ||
'css': '@import "{filePath}";' | ||
}, | ||
'less': | ||
{ | ||
'less': '@import "{filePath}";', | ||
'css': '@import "{filePath}";' | ||
} | ||
@@ -78,0 +86,0 @@ }; |
15609
1.54%226
3.67%