Skip to content

Commit

Permalink
💾 Build files update
Browse files Browse the repository at this point in the history
  • Loading branch information
kobezzza committed Aug 23, 2015
1 parent 1eeddf2 commit cec1ad7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 80 deletions.
62 changes: 7 additions & 55 deletions dist/file.js
@@ -1,11 +1,11 @@
/*!
* Monic v2.3.2
* Monic v2.3.3
* https://github.com/MonicBuilder/Monic
*
* Released under the MIT license
* https://github.com/MonicBuilder/Monic/blob/master/LICENSE
*
* Date: Sun, 23 Aug 2015 12:38:27 GMT
* Date: Sun, 23 Aug 2015 13:08:15 GMT
*/

'use strict';
Expand Down Expand Up @@ -183,11 +183,13 @@ var FileStructure = (function () {
* @param {string} flag - condition
* @param {string} type - condition type
* @param {(boolean|string)=} [opt_value] - condition value
* @param {boolean=} [opt_unless] - unless mode
* @return {!FileStructure}
*/

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

var aliases = {
'=': 'eq',
Expand All @@ -203,7 +205,8 @@ var FileStructure = (function () {
type: aliases[type] || type,
content: [],
varName: flag,
value: opt_value
value: opt_value,
unless: opt_unless
};

this.currentBlock.content.push(ifBlock);
Expand All @@ -220,58 +223,7 @@ var FileStructure = (function () {

FileStructure.prototype.endIf = function endIf() {
if (!({ eq: true, ne: true, gt: true, gte: true, lt: true, lte: true })[this.currentBlock.type]) {
throw new SyntaxError('Attempt to close an unopened block "#if"');
}

this.currentBlock = this.currentBlock.parent;
return this;
};

/**
* Sets a condition
*
* @param {string} flag - condition
* @param {string} type - condition type
* @param {(boolean|string)=} [opt_value] - condition value
* @return {!FileStructure}
*/

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

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

var ifBlock = {
parent: this.currentBlock,
type: aliases[type] || type,
unless: true,
content: [],
varName: flag,
value: opt_value
};

this.currentBlock.content.push(ifBlock);
this.currentBlock = ifBlock;

return this;
};

/**
* Ends a condition
*
* @return {!FileStructure}
*/

FileStructure.prototype.endUnless = function endUnless() {
if (!({ eq: true, ne: true, gt: true, gte: true, lt: true, lte: true })[this.currentBlock.type]) {
throw new SyntaxError('Attempt to close an unopened block "#if"');
throw new SyntaxError('Attempt to close an unopened block "#' + (this.currentBlock.unless ? 'unless' : 'if') + '"');
}

this.currentBlock = this.currentBlock.parent;
Expand Down
33 changes: 8 additions & 25 deletions dist/parser.js
@@ -1,11 +1,11 @@
/*!
* Monic v2.3.2
* Monic v2.3.3
* https://github.com/MonicBuilder/Monic
*
* Released under the MIT license
* https://github.com/MonicBuilder/Monic/blob/master/LICENSE
*
* Date: Sun, 23 Aug 2015 12:38:27 GMT
* Date: Sun, 23 Aug 2015 13:08:15 GMT
*/

'use strict';
Expand Down Expand Up @@ -532,9 +532,10 @@ var Parser = (function () {
* @private
* @param {!FileStructure} struct - file structure
* @param {string} value - directive value
* @param {boolean=} [opt_unless] - unless mode
*/

Parser.prototype._if = function _if(struct, value) {
Parser.prototype._if = function _if(struct, value, opt_unless) {
value = value.trim();

var args = value.split(/\s+/);
Expand All @@ -550,10 +551,10 @@ var Parser = (function () {
}

if (!value || args.length !== 3) {
throw new SyntaxError('Bad "#if" directive');
throw new SyntaxError('Bad "#' + (opt_unless ? 'unless' : 'if') + '" directive');
}

struct.beginIf.apply(struct, args);
struct.beginIf.apply(struct, args.concat(opt_unless));
};

/**
Expand All @@ -576,25 +577,7 @@ var Parser = (function () {
*/

Parser.prototype._unless = function _unless(struct, value) {
value = value.trim();

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 "#unless" directive');
}

struct.beginUnless.apply(struct, args);
this._if(struct, value, true);
};

/**
Expand All @@ -605,7 +588,7 @@ var Parser = (function () {
*/

Parser.prototype._endunless = function _endunless(struct) {
struct.endUnless();
struct.endIf();
};

/**
Expand Down

0 comments on commit cec1ad7

Please sign in to comment.