Answer the question
In order to leave comments, you need to log in
How not to skip css class in commit?
There is a simple project. Written in 11ty. It uses the Nunjucks template engine.
The essence of the problem: sometimes for debugging in one specific file for one specific html element, a class is added. But it is very important that this class does not get into the production and be deleted before the commit.
How can this be resolved? Use an html validator and somehow implement your own rules into it? Or use some kind of framework for tests and already inside it parse html and check it yourself? And what is customary to check in such cases: the file with the source code, or the final html?
Answer the question
In order to leave comments, you need to log in
Perhaps I misunderstand the task, but what prevents you from passing a variable to Nunjucks and using it for conditional rendering?
What I mean: WebPack
example : nunjucks.config.js
module.exports = {
data: {
isDev: process.env.NODE_ENV === 'development'
}
}
<div {% if isDev %} class="debug" {% endif %} ></div>
<!-- or -->
<div class="{{ 'debug' if isDev }}"></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question