A
A
Abwel2021-09-01 13:33:36
Layout
Abwel, 2021-09-01 13:33:36

${variable} doesn't work in Pug preprocessor, what to do?

Good afternoon, but I can’t continue the project further. For some reason, this construction does not work for me
- var www = 'row_expand.png';
- var img_row = require(`../../../components/length-stay/${www}`);
I pass the img_row variable to the mixin, but everything immediately breaks. It only works like this:
- var img_row = require(`../../../components/length-stay/row_expand.png`); - if you write directly on the forehead.
Help - this is very important, I have a component structure in my project, and I definitely need to be able to operate with variables in the paths.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
inkShio, 2021-09-01
@inkShio

#{www}
interpolation

R
ramanovsky, 2021-09-02
@ramanovsky

Try like this. The second one must earn 100%.

// 1. Вариант
- var img_row = require(`../../../components/length-stay/#[www]`);
// 2. Вариант
- var img_row = require('../../../components/length-stay/' + www);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question