diff options
Diffstat (limited to 'lib/handlebars/helpers/helper-missing.js')
-rw-r--r-- | lib/handlebars/helpers/helper-missing.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/handlebars/helpers/helper-missing.js b/lib/handlebars/helpers/helper-missing.js new file mode 100644 index 0000000..ec32e82 --- /dev/null +++ b/lib/handlebars/helpers/helper-missing.js @@ -0,0 +1,13 @@ +import Exception from '../exception'; + +export default function(instance) { + instance.registerHelper('helperMissing', function(/* [args, ]options */) { + if (arguments.length === 1) { + // A missing field in a {{foo}} construct. + return undefined; + } else { + // Someone is actually trying to call something, blow up. + throw new Exception('Missing helper: "' + arguments[arguments.length - 1].name + '"'); + } + }); +} |