V
V
Vazgen Aleksanyan2019-03-03 18:24:53
JavaScript
Vazgen Aleksanyan, 2019-03-03 18:24:53

The variable passed to the .pug mixin is not visible in the script, what can I do?

5c7bf0d4ec2ac790758594.jpeg
this is a regular mixin in a pug file, every time I add it to index.pug I need this function to be called with the same parameters that are passed to the mixin. but these variables are not visible in the script, maybe there is another option?
Now I do it this way - every time I call the function along with the mixin in index.pug
5c7bf1bc87fc0686863534.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
monochromer, 2019-03-03
@VazgXa

mixin chart(value)
  script.
    updateChart(#{value})
    
+chart(10)

In general, it is not safe to generate such js code on the server side. It is better to write initial values, for example, to hidden inputs and read values ​​from them with some validation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question