From bf77e20c55284049010dcd2c4fcb942bb8efcfd2 Mon Sep 17 00:00:00 2001 From: fool2fish Date: Mon, 23 Jun 2014 14:33:40 +0800 Subject: [PATCH] Give a warning when calls undefined macro. --- examples/data-structure/index.vm | 2 ++ lib/data/data-direc.js | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/data-structure/index.vm b/examples/data-structure/index.vm index 7205f96..3ca2421 100644 --- a/examples/data-structure/index.vm +++ b/examples/data-structure/index.vm @@ -6,6 +6,8 @@ $user.favorites[$favIdx] $order.orderId +#undfinedMacro() + #set($temp = 1) #set($addr = $order.addr) $addr.zipCode diff --git a/lib/data/data-direc.js b/lib/data/data-direc.js index d9f9367..b99c1fa 100644 --- a/lib/data/data-direc.js +++ b/lib/data/data-direc.js @@ -167,12 +167,13 @@ module.exports = { var definition = this.template.__macro[name] || this.macro[name] if (!definition) { - this.throwError('Call undefined macro.', node.pos) + logger.warn('Call undefined macro <', name, '>') + return } - var definitionTempl = name in this.template.__macro ? this.template : definition.__template - if (!definition.body) return + var definitionTempl = name in this.template.__macro ? this.template : definition.__template + var ctx = {} var args = node.arguments var argsLen = args.length