Skip to content

Commit

Permalink
Merge pull request #24 from riot/dev
Browse files Browse the repository at this point in the history
v2.3.13
  • Loading branch information
aMarCruz committed Nov 20, 2015
2 parents 921294c + bc14709 commit aecde8b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ Enhancements
- In the JavaScript, trailing whitespace are removed and multiple empty lines are combined into one.
- Better recognition of expressions. Now you can use almost any character, even in unquoted expressions (expressions containing the `>` operator needs to be enclosed in quotes) - [riot#744](https://github.com/riot/riot/issues/744)
- If the first character inside an expression is `^`, the expression is not passed to any parser. This is some sort of type=none at expression level - [riot#543](https://github.com/riot/riot/issues/543) and [riot#1090](https://github.com/riot/riot/issues/1090)
- Type es6 now supports babel-core - [riot#1039](https://github.com/riot/riot/issues/1039)
- Type es6 now supports babel-core - [riot#1039](https://github.com/riot/riot/issues/1039)
- New logic for scoped style blocks, if a style contains the ":scoped" selector, this is replaced by the name of the root element, if not, the name is prepended - [riot#912](https://github.com/riot/riot/issues/912)
- `type="scoped-css"` for `style` tags is deprecated, use only `scoped` or `scoped="scoped"`
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@

`$ bower install riot-compiler --save`

### For babel users

Due to recent changes in the babel API, from v2.3.0-beta.7 we are supporting `babel` versions previous to 6.0.2 through `parsers.css.es6` (`<script type="es6">`), new versions are not compatible with the node API.
### Read more in the [doc folder](doc/) and the [CHANGELOG](CHANGELOG.md)

For `babel-core`, please use the new `parsers.css.babel` (`<script type="babel">`). You must `npm install babel-preset-es2015` too, for this works.
_Please note: the documentation is a work in progress. Contributions are welcome._

#### For babel users

Due to changes in the babel API, from our v2.3.0-beta.7 we are separating the babel support in the following types:

* es6 - For `babel` and `babel-core` v5.8.x and below
* babel - For `babel-core` v6.x - You must `npm install babel-preset-es2015` too, for this works.


[travis-image]:https://img.shields.io/travis/riot/compiler.svg?style=flat-square
Expand Down
8 changes: 4 additions & 4 deletions dist/compiler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* riot-compiler v2.3.12, @license MIT, (c) 2015 Muut Inc. + contributors */
/* riot-compiler WIP, @license MIT, (c) 2015 Muut Inc. + contributors */
;(function (root, factory) {

/* istanbul ignore else */
Expand Down Expand Up @@ -403,7 +403,6 @@
}

function compileCSS(style, tag, type, scoped, opts) {
if (!type) type = opts.style

if (type) {
if (type === 'scoped-css') {
Expand Down Expand Up @@ -562,9 +561,10 @@
body = body.replace(_regEx('^' + indent, 'gm'), '')

body = body.replace(STYLE, function (_, _attrs, _style) {
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs)
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs),
csstype = getType(_attrs) || opts.style
styles += (styles ? ' ' : '') +
compileCSS(_style, tagName, getType(_attrs), scoped, getParserOptions(_attrs))
compileCSS(_style, tagName, csstype, scoped, getParserOptions(_attrs))
return ''
})

Expand Down
8 changes: 4 additions & 4 deletions dist/riot.compiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/**
* Compiler for riot custom tags
* @version v2.3.12
* @version WIP
*/

/**
Expand Down Expand Up @@ -334,7 +334,6 @@ var compile = (function () {
}

function compileCSS(style, tag, type, scoped, opts) {
if (!type) type = opts.style

if (type) {
if (type === 'scoped-css') {
Expand Down Expand Up @@ -490,9 +489,10 @@ var compile = (function () {
body = body.replace(_regEx('^' + indent, 'gm'), '')

body = body.replace(STYLE, function (_, _attrs, _style) {
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs)
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs),
csstype = getType(_attrs) || opts.style
styles += (styles ? ' ' : '') +
compileCSS(_style, tagName, getType(_attrs), scoped, getParserOptions(_attrs))
compileCSS(_style, tagName, csstype, scoped, getParserOptions(_attrs))
return ''
})

Expand Down
6 changes: 3 additions & 3 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ var compile = (function () {
* @returns {string} The processed style block
*/
function compileCSS(style, tag, type, scoped, opts) {
if (!type) type = opts.style

if (type) {
if (type === 'scoped-css') { // DEPRECATED
Expand Down Expand Up @@ -573,9 +572,10 @@ var compile = (function () {

// get and process the style blocks
body = body.replace(STYLE, function (_, _attrs, _style) {
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs)
var scoped = _attrs && /\sscoped(\s|=|$)/i.test(_attrs),
csstype = getType(_attrs) || opts.style
styles += (styles ? ' ' : '') +
compileCSS(_style, tagName, getType(_attrs), scoped, getParserOptions(_attrs))
compileCSS(_style, tagName, csstype, scoped, getParserOptions(_attrs))
return ''
})

Expand Down
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.3.12",
"version": "2.3.13",
"description": "Compiler for riot .tag files",
"main": "dist/compiler.js",
"directories": {
Expand Down
16 changes: 16 additions & 0 deletions test/specs/parsers/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ describe('Style parsers', function () {
testParser('mixed-css', {})
})

it('The style option for setting the CSS parser (v2.3.13)', function () {
var
source = [
'<style-option>',
' <style>',
' p {top:0}',
' </style>',
'</style-option>'
].join('\n'),
result

compiler.parsers.css.myParser2 = function (t, s) { return s.replace(/\bp\b/g, 'P') }
result = compiler.compile(source, {style: 'myParser2'})
expect(result).to.contain('P {top:0}')
})

})

describe('Other', function () {
Expand Down

0 comments on commit aecde8b

Please sign in to comment.