刀片服务器模板未执行@else子句 [英] Blade template not executing @else clause

查看:60
本文介绍了刀片服务器模板未执行@else子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Blade模板,可加载用户列表并显示其各种详细信息.

I have a Blade template that loads a list of users and displays their various details.

如果用户没有手机号码,我想显示消息没有手机号码"(我尝试使用单引号和双引号),则永远不会显示该信息:

If a user has no mobile number I want to display the message "No Mobile Number" (I've tried single and double quotes), this never gets displayed:

@if ($person->Mobile >= "")
    {{ $person->Mobile }}
@else
    'No Mobile Number' 
@endif

我尝试用{{$ person-> Email}}代替"No Mobile"消息(该消息显示在其他地方,所以我知道每个人都有一个电子邮件地址),但尽我所能告诉逻辑不会进入@else块.
有什么想法吗?

I tried substituting the "No Mobile" message with {{ $person->EMail }} (which I'm displaying elsewhere, so I know everyone has an email address), but still go nothing, as far as I can tell the logic isn't going into the @else block.
Any ideas?

推荐答案

这应该有效

@if (!empty($person->Mobile))
    {{{ $person->Mobile }}}
@else
    'No Mobile Number' 
@endif

这篇关于刀片服务器模板未执行@else子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆