简体   繁体   中英

Laravel Blade Localization in if statement

I am trying to create an if statement in a Laravel 5.2 blade template with the localization trans() function.

What I want to achieve is that if the content I am calling is 'true' I would like to show an image - else just print '-' to the website.

The code so far looks like this:

    <div class="table-cell">
      @if (trans('content.offer.text') == 'true')
        <img src="../images/tick.png" class="img-responsive" />
      @else
        -
    </div>

Informatin to the code: The localization file exists, also the entry exists and I wrote it correctly - if I just echo it, it says true on the website. The content of the value is 'true' or 'false':

    'text' => 'true',

However, this is giving me a "parse error" message without much useful information (it literally just says: "Fatal Error - parse error").

My question: How do I write this if statement with the localization function trans() correctly?

Thank you in advance :)

啊,我的dumdum ......我没有意识到如果在@if之后有一个@else,@ if还需要一个@endif。抱歉打扰了所有的读者。

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