Skip to content

Commit

Permalink
chore(all): prepare release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 12, 2015
1 parent b07b1f8 commit 6591464
Show file tree
Hide file tree
Showing 11 changed files with 1,036 additions and 606 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-templating-binding",
"version": "0.6.0",
"version": "0.7.0",
"description": "An implementation of the templating engine's Binding Language abstraction which uses a pluggable command syntax.",
"keywords": [
"aurelia",
Expand Down
151 changes: 102 additions & 49 deletions dist/amd/binding-language.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
define(["exports", "aurelia-templating", "aurelia-binding", "./syntax-interpreter"], function (exports, _aureliaTemplating, _aureliaBinding, _syntaxInterpreter) {
"use strict";

var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};

var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
Expand All @@ -20,10 +25,14 @@ define(["exports", "aurelia-templating", "aurelia-binding", "./syntax-interprete
var Parser = _aureliaBinding.Parser;
var ObserverLocator = _aureliaBinding.ObserverLocator;
var BindingExpression = _aureliaBinding.BindingExpression;
var NameExpression = _aureliaBinding.NameExpression;
var ONE_WAY = _aureliaBinding.ONE_WAY;
var SyntaxInterpreter = _syntaxInterpreter.SyntaxInterpreter;
var TemplatingBindingLanguage = (function () {
var _BindingLanguage = BindingLanguage;


var info = {};

var TemplatingBindingLanguage = (function (BindingLanguage) {
var TemplatingBindingLanguage = function TemplatingBindingLanguage(parser, observerLocator, syntaxInterpreter) {
this.parser = parser;
this.observerLocator = observerLocator;
Expand All @@ -32,63 +41,107 @@ define(["exports", "aurelia-templating", "aurelia-binding", "./syntax-interprete
syntaxInterpreter.language = this;
};

_inherits(TemplatingBindingLanguage, _BindingLanguage);

TemplatingBindingLanguage.inject = function () {
return [Parser, ObserverLocator, SyntaxInterpreter];
};
_inherits(TemplatingBindingLanguage, BindingLanguage);

TemplatingBindingLanguage.prototype.parseAttribute = function (resources, element, attrName, attrValue, existingInstruction) {
var parts = attrName.split("."), instruction;

if (parts.length == 2) {
instruction = this.syntaxInterpreter.interpret(parts[1].trim(), resources, element, parts[0].trim(), attrValue, existingInstruction);

if (!existingInstruction) {
instruction.originalAttrName = attrName;
}
} else {
var expression = this.parseContent(resources, attrName, attrValue);
if (expression) {
instruction = existingInstruction || { attrName: attrName, attributes: {} };
instruction.attributes[attrName] = expression;
}
_prototypeProperties(TemplatingBindingLanguage, {
inject: {
value: function () {
return [Parser, ObserverLocator, SyntaxInterpreter];
},
writable: true,
enumerable: true,
configurable: true
}
}, {
inspectAttribute: {
value: function (resources, attrName, attrValue) {
var parts = attrName.split(".");

if (parts.length == 2) {
info.attrName = parts[0].trim();
info.attrValue = attrValue;
info.command = parts[1].trim();
info.expression = null;
} else if (attrName == "ref") {
info.attrName = attrName;
info.attrValue = attrValue;
info.command = null;
info.expression = new NameExpression(attrValue, "element");
} else {
info.attrName = attrName;
info.attrValue = attrValue;
info.command = null;
info.expression = this.parseContent(resources, attrName, attrValue);
}

return info;
},
writable: true,
enumerable: true,
configurable: true
},
createAttributeInstruction: {
value: function (resources, element, info, existingInstruction) {
var instruction;

if (info.expression) {
if (info.attrName === "ref") {
return info.expression;
}

instruction = existingInstruction || { attrName: info.attrName, attributes: {} };
instruction.attributes[info.attrName] = info.expression;
} else if (info.command) {
instruction = this.syntaxInterpreter.interpret(resources, element, info, existingInstruction);
}

return instruction;
},
writable: true,
enumerable: true,
configurable: true
},
parseText: {
value: function (resources, value) {
return this.parseContent(resources, "textContent", value);
},
writable: true,
enumerable: true,
configurable: true
},
parseContent: {
value: function (resources, attrName, attrValue) {
var expressionText, expression;

return instruction;
};

TemplatingBindingLanguage.prototype.parseText = function (resources, value) {
return this.parseContent(resources, "textContent", value);
};

TemplatingBindingLanguage.prototype.parseContent = function (resources, attrName, attrValue) {
var expressionText, expression;
var parts = attrValue.split(this.interpolationRegex);
if (parts.length <= 1) {
return null;
}

var parts = attrValue.split(this.interpolationRegex);
if (parts.length <= 1) {
return null;
}
parts.forEach(function (part, index) {
if (index % 2 === 0) {
parts[index] = "'" + part + "'";
} else {
parts[index] = "(" + part + ")";
}
});

parts.forEach(function (part, index) {
if (index % 2 === 0) {
parts[index] = "'" + part + "'";
} else {
parts[index] = "(" + part + ")";
}
});
expressionText = parts.join("+");

expressionText = parts.join("+");
expression = new BindingExpression(this.observerLocator, attrName === "class" ? "className" : attrName, this.parser.parse(expressionText), ONE_WAY, resources.valueConverterLookupFunction);

expression = new BindingExpression(this.observerLocator, attrName === "class" ? "className" : attrName, this.parser.parse(expressionText), ONE_WAY, resources.valueConverterLookupFunction);
expression.attribute = attrName;

expression.attribute = attrName;

return expression;
};
return expression;
},
writable: true,
enumerable: true,
configurable: true
}
});

return TemplatingBindingLanguage;
})();
})(BindingLanguage);

exports.TemplatingBindingLanguage = TemplatingBindingLanguage;
});
Loading

0 comments on commit 6591464

Please sign in to comment.