Skip to content

Commit

Permalink
feat(): add parser query option
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky authored Jul 29, 2016
2 parents a20869e + fd79957 commit 6650acc
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 6650acc

Please sign in to comment.