K
K
Kotaro Hiba2020-01-21 05:32:46
Pug
Kotaro Hiba, 2020-01-21 05:32:46

Is it possible to include a specific pug file when calling a webpack mixin?

Hello, webpack has a very cool plugin called
ProvidePlugin - which includes the necessary libraries if it finds the specified symbol in the file,
or sass-resources-loader which automatically includes sass files with mixin functions and variables, is there such a feature for pug / jade ?? It’s just that there is code that I constantly copy from one mixin to another, I would like to just make a separate mixin for this code to shorten the code.
Did some digging with mixins in pug, thinking to expand my question, here is the code

-
    var classes = 'bullet-list'
    classes += options.element ? ' ' + options.element + '__bullet-list' : ''
    classes += options.mode ? ' bullet-list_' + options.mode : ''
    classes += options.state ? ' bullet-list_state_' + options.state : ''
    classes += options.addAnyClass ? ' ' + options.addAnyClass : ''

i.e. when we create a mixin, we do this
+bullet-list({
element: 'header',
mode: 'black'
}),
during the assembly of the file, it helps to quickly set the desired class to the block, of which it is an element or a modifier, I wanted to take it out this is in a separate mixin so as not to pile up the same code in each block, but simply call +classes() -> (in theory, it should return the string 'header__bullet-list bullet-list_black'), but it seems that I began to understand that pug does not work like that or there is some then the exit?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question