Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print variables inside jade file

I want to print default value for my forms textarea i have bellow code

 textarea(class="form-control",name="details")
     if restaurant.details
          #{restaurant.details}

but if my value ( restaurant.details ) is set it will apears like tag not text, how can print text inside my textarea?

like image 788
Mohamad Ali Avatar asked Feb 15 '14 18:02

Mohamad Ali


2 Answers

Use the | operator:

 textarea(class="form-control",name="details")
     if restaurant.details
       | #{restaurant.details}

codepen

From the docs

The simplest way of adding plain text to templates is to prefix the line with a | character (pronounced "pipe").

like image 146
Nick Tomlin Avatar answered Nov 01 '22 00:11

Nick Tomlin


By using !{...} instead of #{...}, you will get string exactly without compilation / interpolation.

like image 4
Piya Poonsawat Avatar answered Nov 01 '22 00:11

Piya Poonsawat