diff --git a/src/js/optionsMacro.js b/src/js/optionsMacro.js index 3e089e5815aaaf2e5a826bdbfec06d9de81d6e77..b4d81c6d548aecbba2d12f180509f62df7af8a56 100644 --- a/src/js/optionsMacro.js +++ b/src/js/optionsMacro.js @@ -31,12 +31,13 @@ Macro.add('options', { var comment = null; var hasMultipleOptionsWithSameValue = false; var description = ""; + var hasCurrentOption = this.payload[0].args.full && + this.payload[0].args.full !== '""' && this.payload[0].args.full !== "''"; /* Check if we have a first argument - if we do, it should be a variable like $foo */ - if (this.payload[0].args.full && - this.payload[0].args.full !== '""' && this.payload[0].args.full !== "''") { + if (hasCurrentOption) { if (currentOption === undefined) currentOption = false; if (this.payload[0].args.full.startsWith("State.temporary.")) { @@ -95,6 +96,21 @@ Macro.add('options', { throw new Error("Only valid tag is 'option' inside 'options'"); } } + } else { + // No variable was passed to <<options>> + // This is valid, but then we only allow an empty <<option>> or <<comment>> + // inside + for (let i = 1, len = this.payload.length; i < len; ++i) { + if (this.payload[i].name === 'option' && this.payload[i].args.length === 0) { + // This is valid for an empty <<options>> + } else if (this.payload[i].name === "comment") { + // This is valid for an empty <<options>> + } else { + throw new Error("Missing variable to <<options>>"); + } + + } + } var showSelectedOption = true; //this.payload.length !== 3 || !description;