A
A
Alexander2015-11-13 17:50:32
Node.js
Alexander, 2015-11-13 17:50:32

How to pass variable to js part of jade template?

There is a jade template with a case. How to pass the value of the name variable to this case?

case name
 when 'Вася'
  p Васильевич
 when 'Петя'
  p Петрович

I tried to assign to the variable the value passed by the server side - var name = #{name}, and only then push it into the case, but then it gives an error
SyntaxError: Unexpected character '#' (04:11)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amatory10, 2015-11-13
@Ky6uk-Hy6uk

When you assign a value to a variable, you don't need to use #. this construction is used for interpolation. Just use name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question