gpt4 book ai didi

boolean - 使用 Freemarker 将字符串转换为 boolean 值

转载 作者:行者123 更新时间:2023-12-05 04:06:40 25 4
gpt4 key购买 nike

如何将字符串“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=trueexternalLink=false

关于boolean - 使用 Freemarker 将字符串转换为 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49676303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com