Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
kobezzza committed Aug 23, 2015
1 parent 66568ec commit 37c5d92
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 66 deletions.
38 changes: 23 additions & 15 deletions README.md
Expand Up @@ -338,35 +338,43 @@ alert('Cool!');
The `#match` provides the most flexible interface to work with conditions.

```js
//#set ie 7
//#set foo

//#match eq ie 7
alert('eq ie 7');
//#match foo
alert('foo');
/*? Or //#end match */
//#endmatch

//#match ne ie 8
alert('ne ie 8');
//#unset foo

//#match foo !=
alert('foo !=');
//#endmatch

//#set ie 7

//#match ie = 7
alert('ie = 7');
//#endmatch

//#match ne ie 7
alert('ne ie 7');
//#match ie != 8
alert('ie != 8');
//#endmatch

//#match gt ie 6
alert('gt ie 6');
//#match ie > 6
alert('ie > 6');
//#endmatch

//#match gte ie 7
alert('gte ie 7');
//#match ie >= 7
alert('ie >= 7');
//#endmatch

//#match lt ie 8
alert('lt ie 6');
//#match ie < 8
alert('ie < 8');
//#endmatch

//#match lte ie 7
alert('lte ie 7');
//#match ie <= 7
alert('ie <= 7');
//#endmatch
```

Expand Down
38 changes: 23 additions & 15 deletions README.ru.md
Expand Up @@ -336,35 +336,43 @@ alert('Cool!');
Директива `#match` предоставляет самый гибкий интерфейс для работы с условиями.

```js
//#set ie 7
//#set foo

//#match eq ie 7
alert('eq ie 7');
//#match foo
alert('foo');
/*? Можно использовать //#end match */
//#endmatch

//#match ne ie 8
alert('ne ie 8');
//#unset foo

//#match foo !=
alert('foo !=');
//#endmatch

//#set ie 7

//#match ie = 7
alert('ie = 7');
//#endmatch

//#match ne ie 7
alert('ne ie 7');
//#match ie != 8
alert('ie != 8');
//#endmatch

//#match gt ie 6
alert('gt ie 6');
//#match ie > 6
alert('ie > 6');
//#endmatch

//#match gte ie 7
alert('gte ie 7');
//#match ie >= 7
alert('ie >= 7');
//#endmatch

//#match lt ie 8
alert('lt ie 6');
//#match ie < 8
alert('ie < 8');
//#endmatch

//#match lte ie 7
alert('lte ie 7');
//#match ie <= 7
alert('ie <= 7');
//#endmatch
```

Expand Down
16 changes: 11 additions & 5 deletions dist/file.js
@@ -1,11 +1,11 @@
/*!
* Monic v2.3.0
* Monic v2.3.1
* https://github.com/MonicBuilder/Monic
*
* Released under the MIT license
* https://github.com/MonicBuilder/Monic/blob/master/LICENSE
*
* Date: Sun, 23 Aug 2015 10:36:26 GMT
* Date: Sun, 23 Aug 2015 12:03:35 GMT
*/

'use strict';
Expand Down Expand Up @@ -180,18 +180,24 @@ var FileStructure = (function () {
/**
* Sets matching
*
* @param {string} type - condition type
* @param {string} flag - condition
* @param {string} type - condition type
* @param {(boolean|string)=} [opt_value] - condition value
* @return {!FileStructure}
*/

FileStructure.prototype.beginMatch = function beginMatch(type, flag) {
FileStructure.prototype.beginMatch = function beginMatch(flag, type) {
var opt_value = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];

var aliases = {
eq: 'if',
ne: 'unless'
ne: 'unless',
'=': 'if',
'!=': 'unless',
'>': 'gt',
'>=': 'gte',
'<': 'lt',
'<=': 'lte'
};

var ifBlock = {
Expand Down
20 changes: 16 additions & 4 deletions dist/parser.js
@@ -1,11 +1,11 @@
/*!
* Monic v2.3.0
* Monic v2.3.1
* https://github.com/MonicBuilder/Monic
*
* Released under the MIT license
* https://github.com/MonicBuilder/Monic/blob/master/LICENSE
*
* Date: Sun, 23 Aug 2015 10:36:26 GMT
* Date: Sun, 23 Aug 2015 12:03:35 GMT
*/

'use strict';
Expand Down Expand Up @@ -537,11 +537,23 @@ var Parser = (function () {
Parser.prototype._match = function _match(struct, value) {
value = value.trim();

if (!value) {
var args = value.split(/\s+/);

switch (args.length) {
case 1:
args.push('eq', true);
break;

case 2:
args.push(true);
break;
}

if (!value || args.length !== 3) {
throw new SyntaxError('Bad "#match" directive');
}

struct.beginMatch.apply(struct, value.split(/\s+/));
struct.beginMatch.apply(struct, args);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion monic.js
Expand Up @@ -21,7 +21,7 @@ const
assign = require('object-assign');

/** @type {!Array} */
exports.VERSION = [2, 3, 0];
exports.VERSION = [2, 3, 1];

/**
* Builds a file
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"description": "File builder for JavaScript.",
"homepage": "https://github.com/MonicBuilder/Monic",
"main": "monic.js",
"version": "2.3.0",
"version": "2.3.1",
"license": "MIT",
"author": {
"name": "kobezzza",
Expand Down
12 changes: 9 additions & 3 deletions src/file.js
Expand Up @@ -139,15 +139,21 @@ export class FileStructure {
/**
* Sets matching
*
* @param {string} type - condition type
* @param {string} flag - condition
* @param {string} type - condition type
* @param {(boolean|string)=} [opt_value] - condition value
* @return {!FileStructure}
*/
beginMatch(type, flag, opt_value = true) {
beginMatch(flag, type, opt_value = true) {
const aliases = {
eq: 'if',
ne: 'unless'
ne: 'unless',
'=': 'if',
'!=': 'unless',
'>': 'gt',
'>=': 'gte',
'<': 'lt',
'<=': 'lte'
};

const ifBlock = {
Expand Down
17 changes: 15 additions & 2 deletions src/parser.js
Expand Up @@ -478,11 +478,24 @@ export default class Parser {
_match(struct, value) {
value = value.trim();

if (!value) {
const
args = value.split(/\s+/);

switch (args.length) {
case 1:
args.push('eq', true);
break;

case 2:
args.push(true);
break;
}

if (!value || args.length !== 3) {
throw new SyntaxError('Bad "#match" directive');
}

struct.beginMatch(...value.split(/\s+/));
struct.beginMatch(...args);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions test/match-01/result.js
@@ -1,12 +1,12 @@
alert('eq ie 7');
alert('ie = 7');

alert('ne ie 8');
alert('ie != 8');


alert('gt ie 6');
alert('ie > 6');

alert('gte ie 7');
alert('ie >= 7');

alert('lt ie 6');
alert('ie < 8');

alert('lte ie 7');
alert('ie <= 7');
28 changes: 14 additions & 14 deletions test/match-01/test.js
@@ -1,28 +1,28 @@
//#set ie 7
//#match eq ie 7
alert('eq ie 7');
//#match ie = 7
alert('ie = 7');
//#end match

//#match ne ie 8
alert('ne ie 8');
//#match ie != 8
alert('ie != 8');
//#end match

//#match ne ie 7
alert('ne ie 7');
//#match ie != 7
alert('ie != 7');
//#end match

//#match gt ie 6
alert('gt ie 6');
//#match ie > 6
alert('ie > 6');
//#end match

//#match gte ie 7
alert('gte ie 7');
//#match ie >= 7
alert('ie >= 7');
//#end match

//#match lt ie 8
alert('lt ie 6');
//#match ie < 8
alert('ie < 8');
//#end match

//#match lte ie 7
alert('lte ie 7');
//#match ie <= 7
alert('ie <= 7');
//#end match
3 changes: 3 additions & 0 deletions test/match-02/result.js
@@ -0,0 +1,3 @@
alert('ie');

alert('ie !=');
9 changes: 9 additions & 0 deletions test/match-02/test.js
@@ -0,0 +1,9 @@
//#set ie
//#match ie
alert('ie');
//#end match

//#unset ie
//#match ie !=
alert('ie !=');
//#end match

0 comments on commit 37c5d92

Please sign in to comment.