Laravel Blade, Escape {{ }} Echo

Viewed 1634

I have a textarea tag that I wish to have a default value = {{"example text area"}}

I'm trying to do that with:

<textarea name="" id="" cols="30" rows="10">{{"example text area"}}</textarea> So the output value is exactly {{"example text area"}}

But thw code above will only print example text area

I tried {!!'&#123;&#123;"tre"&#125;&#125;'!!} and the same response above, I also tried {!!'{{"example text area"}}'!!} and it outputs <?php echo e("example text area"); ?>

so how to do it?

3 Answers

One way is to create a variable inside the blade and echoing the variable where necessary like:

//test.blade.php

@php
    $placeholder = "{{example text area}}";
@endphp
<textarea name="" id="" cols="30" rows="10">{{$placeholder}}</textarea>

Simple way would be to echo the necessary value like

<textarea name="" id="" cols="30" rows="10"><?php echo "{{example text area}}" ?></textarea>

If you Laravel Version is greater than 5.1, you can use

<textarea name="" id="" cols="30" rows="10">@{{"gitHub_validation"|translate}}</textarea>

Why are you doing this? If the text doesn't come from crontroller (variable) you can type what you want.

<textarea class="form-control">my default text</textarea>

Or, with a placeholder if matters:

<textarea class="form-control" placeholder="bla"></textarea>

Can you try something like this? if it is static value so you can print them out.

<textarea name="" id="" cols="30" rows="10"><?php echo '{{"gitHub_validation"|translate}}' ?></textarea>
Related