[英]How can I nest Velocity custom directives?
I've created 2 custom directives in Velocity one for internationalization and one for date formatting. 我在Velocity中创建了2个自定义指令,一个用于国际化,一个用于日期格式。 They work great on their own, but now I'm to the point where I need to nest one in the other:
它们自己可以很好地工作,但是现在我到了一个需要嵌套的地步:
#msg('a_resource','TODAY',#date(1234567890900,'date')))!
However this doesn't work as I get the following exception. 但是,这不起作用,因为我收到以下异常。
org.apache.velocity.exception.ParseErrorException: Invalid arg #2 in directive #msg at dateTemplate[line 1, column 5]
How can I call the #date
directive and pass it's value into the other one? 如何调用
#date
指令并将其值传递给另一个指令?
You need to add double quotes around your directive call: "
您需要在指令调用周围添加双引号:
"
#msg('a_resource','TODAY',"#date(1234567890900,'date')"))!
Velocity will evaluate anything in double quotes (like variables, methods, and as needed here: directives) Velocity将用双引号评估任何内容(例如变量,方法,以及根据需要在此处:指令)
See: https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#stringliterals 请参阅: https : //velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#stringliterals
采用:
#msg('a_resource','TODAY',"#date(1234567890900,'date')"))!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.