问题标签 [freemarker]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
6 回答
21410 浏览

java - 从数据库加载 FreeMarker 模板

我想将我的 FreeMarker 模板存储在一个看起来像这样的数据库表中:

当收到对具有特定名称的模板的请求时,这应该会导致执行查询,该查询会加载相关的模板内容。这个模板内容,连同数据模型(上面例子中的“用户”变量的值),应该被传递给 FreeMarker。

但是,FreeMarker API似乎假设每个模板名称对应于文件系统特定目录中的同名文件。有什么方法可以轻松地从数据库而不是文件系统加载模板?

编辑:我应该提到我希望能够在应用程序运行时将模板添加到数据库中,所以我不能简单地在启动时将所有模板加载到新的 StringTemplateLoader 中(如下所示)。

0 投票
2 回答
3377 浏览

java - 绕过 FreeMarker 缓存?

请求某些模板时是否可以绕过 Freemarker 缓存?我意识到我可能必须实现自己的 TemplateLoader 才能做到这一点,但即便如此,当请求模板 A 时,我看不到检查缓存的方法,但在请求模板 B 时绕过它?

如果这是不可能的,我只需要完全禁用缓存。

0 投票
4 回答
2702 浏览

python - 有谁知道 FMPP 的 Python 等价物?

有谁知道文本文件预处理器FMPP的 Python 等效项?

跟进:我正在阅读文档并查看给出的建议的示例。只是为了扩大。我对 FMPP 的使用是读取数据文件 (csv) 并根据该数据使用多个模板来创建链接到主索引的 html 中的多页报告。

0 投票
8 回答
18456 浏览

templates - 在freemarker中交替表格行颜色

使用freemarker进行交替行着色的好方法是什么?

这真的是最好的方法吗?

我试过这样做:

但显然你不能在那里使用三元运算符。

注意:我想我应该在前面提到它,但我不能使用 css 类或 javascript,因为这个 HTML 将进入电子邮件消息。

0 投票
4 回答
2221 浏览

java - Sandboxing Java / Groovy / Freemarker Code - Preventing execution of specific methods

I'm developing a system that allows developers to upload custom groovy scripts and freemarker templates.

I can provide a certain level of security at a very high level with the default Java security infrastructure - i.e. prevent code from accessing the filesystem or network, however I have a need to restrict access to specific methods.

My plan was to modify the Groovy and Freemarker runtimes to read Annotations that would either whitelist or blacklist certain methods, however this would force me to maintain a forked version of their code, which is not desirable.

All I essentially need to be able to do is prevent the execution of specific methods when called from Groovy or Freemarker. I've considered a hack that would look at the call stack, but this would be a massive speed hit (and it quite messy).

Does anyone have any other ideas for implementing this?

0 投票
5 回答
27860 浏览

list - Freemarker中的字符串列表

我在java代码中有一个字符串列表:

我想使用 Freemarker 显示关键字:Apple、Banana

怎么做?

PS:我通读了手册,发现一些建议使用的文章<#list>,但输出是:Apple

香蕉

0 投票
3 回答
2056 浏览

java - 哪种 Java HTML 模板技术的工作方式最接近 Ruby (erb/haml)?

在 Apache Velocity、Freemarker、Hamlets、Tapestry、StringTemplate、JSP、JSP Weaver(其他?)等 Java模板解决方案中,它们最接近 Ruby 中类似 HTML 模板解决方案的简洁性和简单性 - haml/erb。我关心模板引擎的语法以及它与服务器上的控制器代码集成的简单程度。

0 投票
1 回答
1471 浏览

java - 使用 Freemarker 输出 XML

我们在我们的 Web 应用程序中使用 freemarker 作为模板。为此,我们正在使用 spring 的 FreeMarkerViewResolver。

有没有办法在 freemarker 中更改响应的内容类型

文本/xml

有没有办法在模板中做到这一点?

0 投票
3 回答
407 浏览

freemarker - 允许用户编辑其模板时,freemarker 是否安全

我是freemarker的新手,我也需要知道这个问题是否选择,我会自己剥离XSS,但我不知道当站点允许用户编辑他们的模板时freemarker的其他功能是否安全?

0 投票
6 回答
125072 浏览

java - 什么是 FTL 文件

我是一个项目的新手,必须从内到外学习它。我看到很多带有扩展名的文件.ftl。我不确定它们是什么。我知道它们可以被修改,并且用户可以在前端看到变化。