Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass variables to if statement using jade template

Tags:

pug

I'm passing service_type through jade. Trying to compile with service_type = 'gas'.
I tried:

- if(#{service_type}=='gas')
p gas

I've also tried:

- if('#{service_type}'=='gas')
p gas

but neither work... How can I check two strings are equals?

like image 639
Matt Avatar asked Dec 02 '22 00:12

Matt


2 Answers

I got it working correctly without the {}

-if(service_type=='gas') 
  p gas
like image 82
WallMobile Avatar answered Dec 24 '22 07:12

WallMobile


You actually also don't need the initial hyphen at the beginning.

if (service_type=='gas')
    p gas

The above should work just fine also.

like image 38
William Owen Avatar answered Dec 24 '22 09:12

William Owen