- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何将字符串“true”转换为 boolean 值 true
并将“false”转换为 boolean 值 false
?
我这样定义了一些链接:
<#assign mailtoLink =(setting(self, 'my.link.mailto'))! />
...
<#assign links = [
{"linkTarget":mailtoLink, "linkText":mailtoService, "externalLink":"false", "iconName":"#icon-email" },
{"linkTarget":facebookLink, "linkText":facebookService, "externalLink":"true", "iconName":"#icon-facebook" }, ...]/>
内容来自CMS。然后我想使用循环将它们显示在列表中,链接的属性将用作宏的参数:
<ul class="my-options-nav__list">
<#list links as link>
<#if link.linkTarget?has_content>
<li class="bwr-options-nav__list-item">
<@m.link
linkTarget=link.linkTarget
linkText=link.linkText
externalLink=link.externalLink?boolean
linkClass="bwr-link"
iconLeft={"id": "${link.iconName}"}
/>
</li>
</#if>
</#list>
</ul>
我总是从 CoreMedia(或 Freemarker?)得到一个异常(exception):
model
com.coremedia.blueprint.cae.contentbeans.CMChannelImpl$$[id=127994]
view name m.asOptionsNav
view FreemarkerView[template=//WEB-INF/templates/sites/bwr17/com.coremedia.blueprint.common.contentbeans/CMChannel.m.asOptionsNav.ftl]
cause Error rendering view
Error on line 54, column 80, in template /WEB-INF/templates/sites/com.coremedia.blueprint.common.contentbeans/CMChannel.m.asOptionsNav.ftl Found boolean, expecting one of: chunk, is_date, is_hash, float, matches, time, number_to_datetime, byte, substring, is_transform, web_safe, iso_ms_nz, groups, seq_contains, iso, is_method, eval, iso_ms, iso_utc_m_nz, parent, capitalize, number, if_exists, is_directive, iso_utc_h_nz, floor, is_boolean, split, node_name, seq_index_of, is_sequence, sort, is_node, sort_by, xhtml, iso_local_m_nz, iso_nz, node_namespace, date, last_index_of, short, ancestors, length, datetime, iso_local_ms, json_string, reverse, c, keys, iso_local_h_nz, has_content, replace, is_hash_ex, is_number, new, lower_case, string, exists, last, root, j_string, contains, round, long, ends_with, number_to_date, namespace, values, seq_last_index_of, uncap_first, iso_local, is_macro, index_of, word_list, int, iso_utc_nz, xml, double, node_type, rtf, url, iso_m, size, default, iso_h, iso_utc_m, ceiling, iso_h_nz, is_enumerable, iso_utc_h, iso_local_nz, iso_m_nz, left_pad, iso_utc_ms_nz, cap_first, interpret, children, chop_linebreak, is_collection, iso_utc, trim, is_string, number_to_time, upper_case, js_string, right_pad, is_indexable, iso_local_ms_nz, iso_utc_ms, iso_local_h, html, iso_local_m, first, starts_with in /WEB-INF/templates/sites/com.coremedia.blueprint.common.contentbeans/CMChannel.m.asOptionsNav.ftl
最佳答案
问题是您没有将 boolean 值转换为计算机可读格式。
Error on line 54, column 80, in template [...] CMChannel.m.asOptionsNav.ftl Found boolean
See ?c
来自文档
This built-in converts a boolean to string for a "computer language" as opposed to for human audience. [...] When generating JavaScript and such, this should be used
意味着你必须使用
externalLink=(link.externalLink?boolean)?c
为了产生 externalLink=true
或 externalLink=false
关于boolean - 使用 Freemarker 将字符串转换为 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49676303/
我正在使用 freemarker 生成一个 freemarker 模板。但我需要一些方法来转义 freemarker 标签。 我将如何逃脱 标签或 ${expression} ? 最佳答案 您也可以使
我想查看 freemarker 数据模型中的所有变量,就像 struts2 debug标记以显示值堆栈。 freemarker 有没有办法做到这一点? 最佳答案 没有通用的解决方案,但你可以尝试
如何在 freemarker 中连接字符串? 这不起作用。 ${str} = ${str} + ${" world"} ${foo("a")} 这里是在线评估器: http://fre
我创建了一个从 FreeMarker 实现 TemplateMethodModelEx 的类。假装 exec() 函数返回一个字符串: “你好 ${username}” 我将类分配给数据模型中的一个方
Freemarker中内置sort和sort_by是针对list的。如何在 Freemarker 中对对象进行排序?
我正在尝试测试是否可以在 FreeMarker 中将字符串转换为数字。例如,“123”和“3.14”可以转换,但“foo”不能。我知道我可以通过在字符串上使用 number 方法(例如 "123"?n
有没有办法更改 FreeMarker 模板中散列或容器中的子变量?例如,假设我有: {"name":"Bob", "city":"Detroit", "state":"OH"} 我想将状态更改为“MI
如何检查 freemarker 中请求属性的值? 我试过 但出现错误 -> 在行遇到“*” 任何人都可以帮忙吗? 最佳答案 这取决于 Web 应用程序框架,因为 FreeMarker 本身不公开请求
下面的模板有什么问题? package ${packageName} public interface ${entityName} { public void ${methodName}(${map
假设我们有一个简单的 Freemarker 宏: ${expr} ${expr} 给出: 一种 一种 我需要类似的东西 应该给出
在 freemarker 中,我如何确定特定值是否为数字。是否有任何特定方法可以检查给定值是否是 freemarker 中的数字?
我有一个免费标记列表,如下所示: 从上面的列表中,我只想要 v1 和 v2 的子列表。 我一直在徘徊以获取免费标记中的子列表。但是没能找到。 任何帮助将不胜感激。 最佳答案 如果您真的想根据索引制
我正在尝试编写一个 freemarker 模板,其中一个字段值作为数字传递,但我想将其作为字符串打印。目前我正在从 JSON 中获取值。 Freemarker 正在格式化我的情况不需要的数字。例如。如
我正在使用 Freemarker 构建一个站点,并且已经开始大量使用宏。我知道在 Freemarker 2.3 中,将空值作为参数传递给宏相当于根本不传递参数,因此我创建了一个名为“null”的全局变
我正在使用自定义 Magnolia 表单模块(在我公司内部构建)。当用户成功提交表单时,我想将用户重定向到成功页面。 这可以在模块本身中完成。但是,如果用户没有成功提交表单(例如缺少必填字段),我需要
我定义了包含一个参数的自定义宏。它可以是 String或 List . 是否可以检查它是否是数组? 最佳答案 好的,我发现有一些可用的方法,例如 is_... . 这是reference . 对我的情
我有一个 Web 应用程序,我需要手动获取 Freemarker 模板 - 该模板是通过库项目中的类获取的,但实际的 tpl 文件包含在 Web 应用程序类路径中。因此,有 2 个项目,一个是“taa
如何在 Freemarker 中处理 null 值?当数据中存在 null 值时,我在模板中遇到一些异常。 最佳答案 从 freemarker 2.3.7 开始,您可以使用 this syntax :
是否可以在 freemarker 中使用 and(&&) 或者是否必须使用嵌套的 if? 最佳答案 您可以在 Free Maker 中使用 && 作为逻辑运算符。请参阅Logical operat
freemarker比较数字什么最优雅? 这不会包括空检查吗? 如果我这样做 然后 freemarker 会提示不同的类型。 我是这样做的 但我想这不是做事的方式吗?如何在 freemarke
我是一名优秀的程序员,十分优秀!