Skip to content

Commit

Permalink
Give a warning when calls undefined macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
fool2fish committed Jun 23, 2014
1 parent 360cc90 commit bf77e20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/data-structure/index.vm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ $user.favorites[$favIdx]

$order.orderId

#undfinedMacro()

#set($temp = 1)
#set($addr = $order.addr)
$addr.zipCode
Expand Down
7 changes: 4 additions & 3 deletions lib/data/data-direc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf77e20

Please sign in to comment.