Skip to content

Commit

Permalink
Added parser for [bublé](https://buble.surge.sh) as buble.
Browse files Browse the repository at this point in the history
  • Loading branch information
amarcruz committed Aug 26, 2016
1 parent 0ce5dfb commit 77050ad
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ install:

# babel presets
- npm i babel-preset-es2015-riot
- npm i buble
- npm i coffee-script
- npm i livescript
- npm i typescript-simple
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Compiler Changes

### v2.5.4
- Added parser for [bublé](https://buble.surge.sh) as `buble`.

### v2.5.3
- Fix #73 : resolveModuleSource must be a function - Option removed from the default Babel options.
- Updated node.js to 4.4 in the Travis environment.
Expand Down
2 changes: 1 addition & 1 deletion lib/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _parsers = {
var _loaders = {
html: { jade: TRUE, pug: TRUE },
css: { sass: TRUE, scss: TRUE, less: TRUE, stylus: TRUE },
js: { es6: TRUE, babel: TRUE, coffee: TRUE, livescript: TRUE, typescript: TRUE }
js: { es6: TRUE, babel: TRUE, buble: TRUE, coffee: TRUE, livescript: TRUE, typescript: TRUE }
}

_loaders.js.coffeescript = TRUE // 4 the nostalgics
Expand Down
18 changes: 18 additions & 0 deletions lib/parsers/buble.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
bublé 0.13.x JS plugin.
Part of the riot-compiler, license MIT
History
-------
2016-08-26: Initital release
*/
var
mixobj = require('./_utils').mixobj,
parser = require('buble')

module.exports = function _buble (js, opts, url) {

opts = mixobj({ source: url }, opts)

return parser.transform(js, opts).code
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "riot-compiler",
"version": "2.5.2",
"version": "2.5.4",
"description": "Compiler for riot .tag files",
"main": "lib/compiler.js",
"jsnext:main": "dist/es6.compiler.js",
Expand Down
7 changes: 7 additions & 0 deletions test/specs/parsers/_suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ describe('JavaScript parsers', function () {
}
})

// test.buble.tag
it('bublé', function () {
if (have('buble')) {
testParser('test', { type: 'buble' })
}
})

// test-attr.babel.tag (also test alias coffeescript)
it('coffee with shorthands (fix #1090)', function () {
if (have('coffeescript')) {
Expand Down
15 changes: 15 additions & 0 deletions test/specs/parsers/js/test.buble.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

riot.tag2('buble', '<h3>{test}</h3>', '', '', function(opts) {

var this$1 = this;

this.parser = 'Buble'

var type = 'JavaScript'
this.test = "This is " + type + " with " + (this.parser)

this.on('mount', function () {
this$1.parser = 'bublé'
})

});
15 changes: 15 additions & 0 deletions test/specs/parsers/test.buble.tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

<buble>

<h3>{ test }</h3>

this.parser = 'Buble'

const type = 'JavaScript'
this.test = `This is ${ type } with ${ this.parser }`

this.on('mount', () => {
this.parser = 'bublé'
})

</buble>

0 comments on commit 77050ad

Please sign in to comment.