简体   繁体   中英

LARAVEL define variable into blade

in design template i want to define variables to use into html tabs. for example i have two div, parent div is relative and child is absolute . i want to have child smaller than parent.

sample:

{{ WIDTH = 326}}
<div class="win7style" style="margin: 0px auto; {{ WIDTH }}px;">
      <div class="win7style" style="{{ WIDTH - 50 }}px;">

can i define like with that custom variables?

{{...}} is used in laravel-blade for output php variable. You should not define variable in view. Instead define that in controller.

In fact Blade template files are nothing else but usual php files. If you really need to define variables inside the template file, you are free to use plain php code.

<? $width = 326; ?>
<div class="win7style" style="margin: 0px auto; {{ $width }}px;">
      <div class="win7style" style="{{ $width - 50 }}px;">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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