简体   繁体   English

我将带有变量的刀片模板保存在数据库中,如何呈现变量?

[英]I save blade template with variable in database, how to render the variable?

I save plain HTML with variable in database, like this我在数据库中保存带有变量的普通 HTML,就像这样

<div>
        <span>Nomor: <strong>{{ $pen->nomor_sertifikat ?? "" }}</strong></span>
        <span>
            Nilai: <strong>Rp{{ number_format($pen->nilai_pen,0,',','.')}} 
            </strong>
        </span>
</div>

When I call data from database in laravel blade, {,!当我从 laravel 刀片中的数据库调用数据时,{,! $data->content !!}, the result is like this $data->content !!},结果是这样的

Nomor: {{ $pen->nomor_sertifikat }} Nilai: Rp{{ number_format($pen->nilai_pen,0,',','.')}} Nomor: {{ $pen->nomor_sertifikat }} Nilai: Rp{{ number_format($pen->nilai_pen,0,',','.')}}

The data inside {{ }} can't render. {{ }} 内的数据无法呈现。 How to solve it?如何解决?

use利用

 <?= (which you want to input ) ?> 

or或者

<?php echo  (which you want to input ) ?>

but you need to be careful with xss.但是你需要小心xss。 you can use htmlpurifier你可以使用 htmlpurifier

When calling it in a blade template you should put it into {!!在刀片模板中调用它时,您应该将其放入 {!! !!} tags !!} 标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM