Answer the question
In order to leave comments, you need to log in
Why isn't the mixin working in Pug?
Good afternoon.
mixin section(props)
-
var allMods = '';
if(typeof(props.mods) !== 'undefined' && props.mods) {
var modsList = props.mods.split(',');
for (var i = 0; i < modsList.length; i++) {
allMods = allMods + ' section--' + modsList[i].trim();
}
}
-
if(typeof(props.bg) !== 'undefined' && props.mods) {
section(class='section' + allMods style="background-image: url('https://source.unsplash.com/MYlCex1M7Ok/1920x200')")
.container
block
}
section(class='section' + allMods)
.container
block
Answer the question
In order to leave comments, you need to log in
Incorrectly formatted second if. We fix:
mixin section(props)
-
var allMods = '';
if (typeof(props.mods) !== 'undefined' && props.mods) {
var modsList = props.mods.split(',');
for (var i = 0; i < modsList.length; i++) {
allMods = allMods + ' section--' + modsList[i].trim();
}
}
if props.bg && props.mods
section(class='section' + allMods style="background-image: url('https://source.unsplash.com/MYlCex1M7Ok/1920x200')")
.container
block
section(class='section' + allMods)
.container
block
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question