我将用户详细信息发送到视图:
$transformed = new User;
$transformed->firstname = $user->firstname;
$transformed->lastname = $user->lastname;
$transformed->email = $user->email;
return View::make('account.settings', ['user' => $transformed]);
如果我在dd($transformed)
之前View::make
,那么我会看到一个完整的电子邮件地址,但该模板会切断" @"之前:
Should be: parent@parent.com
Is: parent.com
在刀片模板中,我有:
{{ $user->email }}
为什么要切断开始?
这是完整的视图文件:
@extends('account')
@section('content')
<section class="site-section site-content account-section">
<div class="container">
<h1 class="account-header">Account Settings</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
<form role="form" method="POST" action="/auth/register" class="form-horizontal" autocomplete="off">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<h3>Basic Details</h3>
<div class="form-group">
<div class="col-xs-12">
<label for="register-email">Email address</label>
<input id="register-email" type="text" name="email" class="form-control" autocomplete="off" value="{{ $user->email }}">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label for="register-firstname">First Name</label>
<input id="register-firstname" type="text" name="firstname" class="form-control" autocomplete="off" value="{{ $user->firstname }}">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label for="register-lastname">Last Name</label>
<input id="register-lastname" type="text" name="lastname" class="form-control" autocomplete="off" value="{{ $user->lastname }}">
</div>
</div>
<div class="form-group form-actions">
<div class="col-xs-12">
<button type="submit" class="btn btn-block btn-effect-ripple btn-lg btn-success"><i class="fa fa-plus"></i> Update Details</button>
</div>
</div>
<h3>
</h3>
</form>
</div>
</div>
<!-- END row -->
</div>
</section>
@stop
答案 0 :(得分:1)
从评论中可以看出,这是Laravel本身的一个错误,@parent
,@extends
等是刀片模板引擎中的保留字。
简单的解决方法是简单地将@
符号替换为HTML实体等效符号(@
)。所以,请尝试以下代码段:
{{ str_replace('@', '@', $user->email) }}
这也可以在mailto
协议链接中使用,如下所示:
<a href="mailto:{{ str_replace('@', '@', $email) }}">
{{str_replace('@', '@', $email)}}
</a>
供参考,以下是所有HTML实体的列表(列表太长,无法添加到此答案):http://www.ascii.cl/htmlcodes.htm