Answer the question
In order to leave comments, you need to log in
How to use condition in gulp-file-include?
Tell me how to pass data to navbar depending on the page?
The project has two master pages (page1 and page2), which include blocks.
<!DOCTYPE html>
<html lang="ru" data-color-mode="dark">
<head>
...
</head>
<body class="layout">
@@include('./parts/modules/header/header.html')
@@include('./parts/modules/navbar/navbar.html')
@@include('./parts/modules/body/main.html')
@@include('./parts/modules/footer/footer.html')
</body>
</html>
<div class="navbar">
<!--Меню для page1-->
<div class="navbar__list">
<a href="#" class="navbar__item">nav-item1-for-page1</a>
<a href="#" class="navbar__item">nav-item2-for-page1</a>
</div>
<!--Меню для page2-->
<div class="navbar__list">
<a href="#" class="navbar__item">nav-item1-for-page2</a>
<a href="#" class="navbar__item">nav-item2-for-page2</a>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Include a file with a variable:
@@include('./parts/modules/navbar/navbar.html', {
"page": "page1",
})
@@if (page === 'page1') {
<span>Navbar for page 1</span>
}
@@if (page === 'page2') {
<span>Navbar for page 2</span>
}
page
and its values as you like.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question