laravel 4:如何插入原始HTML标签? [英] laravel 4: How insert raw HTML to label?

查看:158
本文介绍了laravel 4:如何插入原始HTML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有简单的方法如何把原始的HTML标签贴上标签?我有这个:

  {{Form :: label('firstName','First name< em> *< em>',array('class'=>'input_tag'))}} 

产生:

 < label class =input_tagfor =firstName>名字< em& gt *安培; LT; / EM&安培; GT;< /标签> 

但是标记EM并不是应该解释的。我想要的是:

 < label class =input_tagfor =firstName>名字< em> * LT; / EM>< /标签> 


解决方案使用 sprintf 中的c $ c>比重新编码快得多:

  Form :: macro('rawLabel',function($ name,$ value = null,$ options = array())
{
$ label = Form :: label($ name,'%s' ,$ options);

返回sprintf($ label,$ value);
});


Is there some easy way how put raw HTML tag to label? I have this:

{{ Form::label('firstName', 'First name <em>*</em>', array('class' => 'input_tag')) }}

and it produces:

<label class="input_tag" for="firstName">First Name &lt;em&gt;*&lt;/em&gt;</label>

BUT tag EM is not interpreted as it should be. What I want is:

<label class="input_tag" for="firstName">First Name <em>*</em></label>

解决方案

Using sprintf in a macro is much faster than redecoding:

Form::macro('rawLabel', function($name, $value = null, $options = array())
{
    $label = Form::label($name, '%s', $options);

    return sprintf($label, $value);
});

这篇关于laravel 4:如何插入原始HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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