diff --git a/README.md b/README.md
index 0a915c5..9a33394 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@ The options are the same as what's supported by `slimrb`.
- `rails: true`
- `translator: true`
- `logicLess: true`
+- `include: true`
Set `bundler: true` to invoke `slimrb` via bundler.
@@ -76,6 +77,24 @@ slim({
pretty: true,
options: ['attr_quote="\'"', 'js_wrapper=:cdata']
})
+
+slim({
+ include: true,
+ options: 'include_dirs="[\'test/fixtures\']"'
+})
+```
+You can also add any other console options for custom slimrb run options. For example:
+
+```javascript
+slim({
+ prerry: true,
+ environment: {
+ cwd: process.cwd(),
+ env: {
+ 'LC_CTYPE':'ru_RU.UTF-8'
+ }
+ }
+})
```
diff --git a/coffee/index.coffee b/coffee/index.coffee
index 6b98e9d..9116ab2 100644
--- a/coffee/index.coffee
+++ b/coffee/index.coffee
@@ -10,6 +10,7 @@ module.exports = (options = {}) ->
# build a command with arguments
cmnd = 'slimrb'
args = []
+ spawn_options = {}
if options.bundler
cmnd = 'bundle'
@@ -29,6 +30,10 @@ module.exports = (options = {}) ->
args.push '-r'
args.push 'slim/logic_less'
+ if options.include
+ args.push '-r'
+ args.push 'slim/include'
+
if options.data
args.push '--locals'
args.push JSON.stringify options.data
@@ -42,6 +47,8 @@ module.exports = (options = {}) ->
args.push '-o'
args.push options.options
+ spawn_options.env = options.environment if options.environment
+
through.obj (file, encoding, callback) ->
if file.isNull()
@@ -55,7 +62,7 @@ module.exports = (options = {}) ->
ext = if options.erb then '.erb' else '.html'
file.path = gutil.replaceExtension file.path, ext
- program = spawn cmnd, args
+ program = spawn cmnd, args, spawn_options
# create buffer
b = new Buffer 0
diff --git a/test/expect/include.html b/test/expect/include.html
new file mode 100644
index 0000000..5a7181a
--- /dev/null
+++ b/test/expect/include.html
@@ -0,0 +1,25 @@
+
+
+
+ Slim Examples
+
+
+
+
+
+
+ Markup examples
+
+
+
+ This example shows you how a basic Slim file looks like.
+
+
This is an included file with custom content
+
+
+
+
diff --git a/test/expect/test-pretty.html b/test/expect/test-pretty.html
index a5b98e5..fabe43d 100644
--- a/test/expect/test-pretty.html
+++ b/test/expect/test-pretty.html
@@ -4,7 +4,7 @@
Slim Examples
-
diff --git a/test/expect/test-single-quotes-cdata.html b/test/expect/test-single-quotes-cdata.html
index 8f183ea..25d9a9f 100644
--- a/test/expect/test-single-quotes-cdata.html
+++ b/test/expect/test-single-quotes-cdata.html
@@ -1,4 +1,4 @@
-Slim ExamplesMarkup examples
This example shows you how a basic Slim file looks like.
+Slim ExamplesMarkup examples
This example shows you how a basic Slim file looks like.
diff --git a/test/expect/test.html b/test/expect/test.html
index 8cd92d4..609fd5c 100644
--- a/test/expect/test.html
+++ b/test/expect/test.html
@@ -1 +1 @@
-Slim ExamplesMarkup examples
This example shows you how a basic Slim file looks like.
+Slim ExamplesMarkup examples
This example shows you how a basic Slim file looks like.
diff --git a/test/fixtures/include-file.slim b/test/fixtures/include-file.slim
new file mode 100644
index 0000000..c04ed9f
--- /dev/null
+++ b/test/fixtures/include-file.slim
@@ -0,0 +1 @@
+blockquote This is an included file with custom content
\ No newline at end of file
diff --git a/test/fixtures/include.slim b/test/fixtures/include.slim
new file mode 100644
index 0000000..3bc9c30
--- /dev/null
+++ b/test/fixtures/include.slim
@@ -0,0 +1,18 @@
+doctype html
+html
+ head
+ title Slim Examples
+ meta name="keywords" content="template language"
+ meta name="author" content="John Doe"
+ javascript:
+ alert('Slim supports embedded javascript!')
+
+ body
+ h1 Markup examples
+
+ #content
+ p This example shows you how a basic Slim file looks like.
+ include include-file
+
+ div id="footer"
+ Copyright © 2014
\ No newline at end of file
diff --git a/test/main.coffee b/test/main.coffee
index f3d503e..493a1f9 100644
--- a/test/main.coffee
+++ b/test/main.coffee
@@ -102,3 +102,20 @@ describe 'gulp-slim', () ->
String(htmlFile.contents).should.equal fs.readFileSync path.join(__dirname, 'expect/data.html'), 'utf8'
done()
stream.write slimFile
+
+ it 'should include additional file with include plugin', (done) ->
+ slimFile = createFile 'include.slim'
+ stream = slim {
+ pretty:true
+ include: true
+ options: ["include_dirs=['test/fixtures']"]
+ }
+ stream.on 'data', (htmlFile) ->
+ should.exist htmlFile
+ should.exist htmlFile.path
+ should.exist htmlFile.relative
+ should.exist htmlFile.contents
+ htmlFile.path.should.equal path.join __dirname, 'fixtures', 'include.html'
+ String(htmlFile.contents).should.equal fs.readFileSync path.join(__dirname, 'expect/include.html'), 'utf8'
+ done()
+ stream.write slimFile