Skip to content

Commit ee97a78

Browse files
Jeff Escalantekylemac
Jeff Escalante
authored andcommitted
jade loader options to accept functions
1 parent 706335b commit ee97a78

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

lib/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default class Config {
4343
syntax: Joi.object()
4444
}),
4545
babelConfig: Joi.object().default({}),
46+
jade: Joi.object().default({}),
4647
dumpDirs: Joi.array().default(['views', 'assets']),
4748
locals: Joi.object().default({}),
4849
ignore: Joi.array().default([]),
@@ -165,6 +166,11 @@ export default class Config {
165166
return opts.postcss
166167
}
167168

169+
this.jade = Object.assign({
170+
locals: this.locals,
171+
pretty: true
172+
}, opts.jade)
173+
168174
this.modulesDirectories = opts.modulesDirectories
169175

170176
// TODO: revisit this before a stable launch

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"postcss-loader": "jenius/postcss-loader",
3737
"require-from-string": "^1.1.0",
3838
"rimraf": "^2.5.2",
39-
"roots-jade-loader": "0.0.2",
39+
"roots-jade-loader": "0.0.3",
4040
"sprout": "^1.0.0",
4141
"webpack": "^1.12.10",
4242
"when": "^3.7.7"

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Option | Description
5757
**matchers** | An object with `jade`, `css`, and `js` keys. Each key is a [micromatch](https://github.com/jonschlinkert/micromatch) string, and represents which files should be pulled into the pipeline to be processed. Defaults are . Be very careful if you are trying to change this. | `**/*.jade`, `**/*.css`, and `**/*.js`
5858
**postcss** | An object that can contain a `plugins` key, which is an array of [plugins to be passed to PostCSS](http://postcss.parts/) for CSS processing, and a `parser`, `stringifier`, and/or `syntax` key, each of which are objects and take [any of the postcss-loader options](https://github.com/postcss/postcss-loader#custom-syntaxes) |
5959
**babelConfig** | A [configuration object for Babel](http://babeljs.io/docs/usage/options/) for JS processing. |
60+
**jade** | A [configuration object for jade](http://jade-lang.com/api/). |
6061
**dumpDirs** | An array of directories which, if direct children of the project root, will dump their contents to the root on compile. Defaults to | `['views', 'assets']`.
6162
**locals** | An object containing locals to be passed to jade views. This can be used for values, functions, any sort of view helper you need. |
6263
**ignore** | An array of [micromatch](https://github.com/jonschlinkert/micromatch) strings, each one defining a file pattern to be ignored from compilation. |

test/fixtures/locals/index.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
= foo
1+
= foo()

test/locals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from './_helpers'
77

88
test('injects template locals', (t) => {
9-
return compileFixture(t, 'locals', { locals: { foo: 'bar' } }).then(({publicPath}) => {
9+
return compileFixture(t, 'locals', { locals: { foo: () => 'bar' } }).then(({publicPath}) => {
1010
return fs.readFile(path.join(publicPath, 'index.html'), 'utf8')
1111
}).then((contents) => {
1212
return t.is(contents, 'bar')

0 commit comments

Comments
 (0)