Andy
Andy

Reputation: 161

Previewing a velocity template

I'm editing velocity templates. these are used to generate PDFs. The problem is that I can't preview them. I can't see how the template will look when rendered. Are there any tools that can be used for that? I've tried googling and I can't find anything.

Editing to add: the templates are rendered by a tool I don't have access to. So if I was to use it I'd have to send it to someone who'd load it everytime I wanted. And they're in a different timezone.

Also, I know if I load it locally it won't show variables. What I'm interested in is knowing what it will look like. The layout etc..,

Upvotes: 7

Views: 10474

Answers (2)

Ori Marko
Ori Marko

Reputation: 58862

There's no Online Velocity Template Tester, There's an option to write test code for velocity

I used to test my velocity with unit tests and created some framework code similar to this approach (https://wiki.apache.org/velocity/TestingVelocity), but more modern (not extending TestCase and so on)

Or different approach but less relevant to you, is to add velocity to jmeter

Put velocity-engine-scripting-2.0.jar in JMeter's lib folder.

When JMeter loaded it can find velocity as scripting engine and use it.

Upvotes: 0

paulo.bing
paulo.bing

Reputation: 90

Would this Apache Velocity Tools help you? The documentation looks a bit old and the user would need a Tomcat server, but it seems do to the job.

Sample of the documentation:

VelocityViewServlet

The VelocityViewServlet class is a standalone servlet that renders Velocity templates. It can be invoked directly from web client's requests, or via servlet forwarding similar to how JSP files are rendered by JSPServlet.

Upvotes: 0

Related Questions