freemark(built-in) 笔记一

博客提及exists、has_content、if_exists,还给出示例,假设不存在名为mouse的变量,说明了相关输出情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 default
如果存在就用本生的值,不存在就用缺省值 
<#assign seq = ['a', 'b']>
${seq[0]?default('-')}
${seq[1]?default('-')}
${seq[2]?default('-')}
${seq[3]?default('-')} 
结果
a
b
-
- 

exists

It is true if the variable exists, otherwise it is false.

has_content

It is true if the variable exists and is not ``empty'', otherwise it is false. The meaning of ``empty'' depends on the concrete case.
expr?if_exists?size > 0 or expr?if_exists?length > 0 instead of expr?has_content.

if_exists

Example. Assume no variable called mouse is present:

(${mouse?if_exists})
Creating mouse...
<#assign mouse = "Jerry">
(${mouse?if_exists})  

The output will be:

()
Creating mouse...
(Jerry)  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值