Skip to content

Commit

Permalink
Fixes #160 - Added error message when w-bind is used, but no correspo…
Browse files Browse the repository at this point in the history
…nding JS module
  • Loading branch information
patrick-steele-idem committed Oct 3, 2016
1 parent 9cf4a97 commit 4aa3460
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions taglib/TransformHelper/handleWidgetBind.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ module.exports = function handleWidgetBind() {

if (bindAttrValue == null) {
modulePath = this.getDefaultWidgetModule();
if (!modulePath) {
this.addError('Invalid "w-bind" attribute. No corresponding JavaScript module found in the same directory (either "widget.js" or "index.js"). Actual: ' + modulePath);
return;
}
} else if (bindAttr.isLiteralValue()) {
modulePath = bindAttr.literalValue; // The value of the literal value
if (typeof modulePath !== 'string') {
Expand Down
7 changes: 7 additions & 0 deletions test/autotests-server/w-bind-missing-widget/index.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = require('marko-widgets').defineComponent({
template: require('./template.marko'),

init: function() {

}
});
1 change: 1 addition & 0 deletions test/autotests-server/w-bind-missing-widget/template.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
div w-bind
7 changes: 7 additions & 0 deletions test/autotests-server/w-bind-missing-widget/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var expect = require('chai').expect;

module.exports = function(helpers) {
expect(function() {
require('./template.marko');
}).to.throw(/Invalid "w-bind" attribute/);
};

0 comments on commit 4aa3460

Please sign in to comment.