有没有一种在传统代码调试意义上调试Velocity模板的方法? [英] Is there a way to debug Velocity templates in the traditional code debugging sense?

查看:475
本文介绍了有没有一种在传统代码调试意义上调试Velocity模板的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Web应用程序中大量使用了Velocity。尽管很容易调试Java事物并确保正确填充Velocity上下文,但是能够在合并步骤中逐步解析VTL,设置断点等非常有价值。是否有任何工具还是可以通过VTL(速度模板语言)使这种事情成为可能的IDE / IDE插件?

We make heavy use of Velocity in our web application. While it is easy to debug the Java side of things and ensure the Velocity Context is populated correctly, it would be extremely valuable to be able to step through the parsing of the VTL on the merge step, set breakpoints, etc. Are there any tools or IDEs/IDE plugins that would make this kind of thing possible with VTL (Velocity Template Language)?

推荐答案

我找不到还没有。我能得到的最接近的方法是 hack 一个日志记录框架,以打印出所需的信息。

I had not found any yet. The closest I can get is to hack a logging framework to print out information that you want.

您要做的是:


  1. 使用日志记录方法创建一个返回布尔值的类。

  2. 将对象注入速度上下文

  3. 从速度模板内部,您可以使用 #if($ logger.log($ data))#end
  4. $调用记录方法b $ b
  1. create an class with logging method which return boolean value.
  2. Inject the object into velocity context
  3. From inside velocity template you can call the logging method with #if($logger.log($data)) #end

这篇关于有没有一种在传统代码调试意义上调试Velocity模板的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆