Velocity template not rendering correctly when filename begins with r
I know this is superstitious, but I see that my template is not rendered correctly when template filename begins with characters such as r,t. The same template renders correctly when the name starts with i, a et开发者_StackOverflowc.
This template should generate one java class per object for a collection of objects. I'm passing the name of the object each time it has to render the template. The file name has a substitution with the name of the object, which works correctly. But the classname(which is the same as the above filename) is not rendered correctly.
Has anyone seen something like this? Are there keywords that should not be part of a template name?
No, the template name is just a string, unless you have some evil custom resource loader that likes to mess with your head.
Oh, and no, i've never heard of such a thing, even in a decade of using and working on Velocity. I think i can safely say this is a first. :)
After a long time, I revisited this and it turns out that it was a bug in my code. As a side effect of one of my actions while rendering a particular template, the contextObject was reset. It had nothing to do with the template name.
Why it failed for r and t is because the side effect occurred in a template whose name started with q. And the templates were picked in alphabetical order.
So all is good now. And velocity is indeed excellent!
精彩评论