Skip to content

Commit

Permalink
add a parser query option
Browse files Browse the repository at this point in the history
  • Loading branch information
btkostner committed Jul 29, 2016
1 parent a20869e commit fd79957
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function parseOptions (config = [], qs = {}) {
// load in the custom parser if there is one
if (config.parser) { res.parser = config.parser }

// try loading custom parser from query
if (qs.parser) {
res.parser = require(qs.parser)
}

return res
}

Expand Down
9 changes: 9 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ test('custom parser', (t) => {
})
})

test('custom parser query', (t) => {
return webpackCompile('custom_parser', {
plugins: [customElements()]
}, '?parser=sugarml').then(({outputPath, src}) => {
t.truthy(src.match(/<div class=\\"custom\\">hello world<\/div>/))
fs.unlinkSync(outputPath)
})
})

test('invalid config', (t) => {
return webpackCompile('custom_parser', 5)
.then(() => t.fail('invalid config, no error'))
Expand Down

0 comments on commit fd79957

Please sign in to comment.