diff --git a/taglibs/core/macro-tag.js b/taglibs/core/macro-tag.js index 9cdef04a4..70f510212 100644 --- a/taglibs/core/macro-tag.js +++ b/taglibs/core/macro-tag.js @@ -1,13 +1,10 @@ module.exports = function codeGenerator(elNode, codegen) { var attributes = elNode.attributes; - if (!attributes.length) { - return; - } - var defAttr = attributes[0]; - if (defAttr.argument == null) { - return; + + if(!defAttr || defAttr.value !== undefined) { + return codegen.addError('The tag must contain a name as its first attribute, example: '); } var body = elNode.body; diff --git a/test/autotests/render/error-macro-no-name/marko.json b/test/autotests/render/error-macro-no-name/marko.json new file mode 100644 index 000000000..35cf25b45 --- /dev/null +++ b/test/autotests/render/error-macro-no-name/marko.json @@ -0,0 +1,5 @@ +{ + "": { + "open-tag-only": true + } +} \ No newline at end of file diff --git a/test/autotests/render/error-macro-no-name/template.marko b/test/autotests/render/error-macro-no-name/template.marko new file mode 100644 index 000000000..adbca906b --- /dev/null +++ b/test/autotests/render/error-macro-no-name/template.marko @@ -0,0 +1,7 @@ + + This is bad. + + + + This is also bad. + \ No newline at end of file diff --git a/test/autotests/render/error-macro-no-name/test.js b/test/autotests/render/error-macro-no-name/test.js new file mode 100644 index 000000000..4ffd94392 --- /dev/null +++ b/test/autotests/render/error-macro-no-name/test.js @@ -0,0 +1,11 @@ +var expect = require('chai').expect; + +exports.templateData = {}; + +exports.checkError = function(e) { + expect(Array.isArray(e.errors)).to.equal(true); + expect(e.errors.length).to.equal(2); + + var message = e.toString(); + expect(message).to.contain('The tag must contain a name as its first attribute, example: '); +}; \ No newline at end of file diff --git a/test/autotests/render/macro-no-args/expected.html b/test/autotests/render/macro-no-args/expected.html index 5ca8959ea..066d4f79f 100644 --- a/test/autotests/render/macro-no-args/expected.html +++ b/test/autotests/render/macro-no-args/expected.html @@ -1 +1 @@ -Marko is awesomeMarko is awesome \ No newline at end of file +Marko is awesomeMarko is awesomeMarko is really awesomeMarko is really awesome \ No newline at end of file diff --git a/test/autotests/render/macro-no-args/template.marko b/test/autotests/render/macro-no-args/template.marko index 34023b780..6113a6674 100644 --- a/test/autotests/render/macro-no-args/template.marko +++ b/test/autotests/render/macro-no-args/template.marko @@ -2,5 +2,11 @@ Marko is awesome + + Marko is really awesome + + - \ No newline at end of file + + + \ No newline at end of file