预览速度模板

发布于 2025-02-04 14:33:32 字数 80 浏览 1 评论 0 原文

我正在编辑速度模板。这些用于生成PDF。问题是我无法预览它们。我看不到模板渲染时的外观。有什么工具可以使用吗?我尝试过谷歌搜索,但找不到任何东西。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

财迷小姐 2025-02-11 14:33:32

不确定这是否解决了您的需求,但是我创建了一个 velocity-template-tester-tester 几年前,当我使用速度模板工作时。它具有一个UI,您可以在其中指定一个模板,例如< html> hello $ {user}</html> 和参数,例如 {“用户”:“ test”} user = test ,它将显示为< html> hello test</html> 显示了扩展的模板。但这不会呈现输出。

如果您的输出将是内部html并且您想要渲染的,则可以使用REST API,它也是。 Postman在 Body> Body 选项卡中具有 Preview 按钮,可用于渲染HTML。 API同时接受JSON和YAML输入。 YAML输入使手动测试多行模板变得更加容易。带有YAML输入的示例API调用看起来如下:

curl --location --request POST 'http://localhost:8080/api/expandTemplate' \
--header 'Content-Type: application/x-yaml' \
--header 'Accept: text/html' \
--data-raw 'template: |
  <html>
    <body>
      Hello ${user}
    </body>
  </html>
parameters:
  user: test'

Not sure if this addresses what you need, but I created a velocity-template-tester a few years ago when I worked with Velocity templates. It has a UI where you can specify a template like <html>Hello ${user}</html> and parameters like {"user":"test"} or user=test and it'll show you the expanded template as <html>Hello test</html>. But it doesn't render the output as such.

If your output will be internally HTML and you want it rendered, you could use a REST API that is also part of the tester in Postman. Postman has a Preview button in the Body tab of the response which can be used to render HTML. The API accepts both JSON and YAML input. YAML input makes it easier to manually test multi-line templates. A sample API call with YAML input looks something like below:

curl --location --request POST 'http://localhost:8080/api/expandTemplate' \
--header 'Content-Type: application/x-yaml' \
--header 'Accept: text/html' \
--data-raw 'template: |
  <html>
    <body>
      Hello ${user}
    </body>
  </html>
parameters:
  user: test'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文