Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Mixin Call (Execute Specific Mixins after all the others) #3442

Open
ComputMagnac opened this issue Jul 13, 2024 · 0 comments
Open

Lazy Mixin Call (Execute Specific Mixins after all the others) #3442

ComputMagnac opened this issue Jul 13, 2024 · 0 comments

Comments

@ComputMagnac
Copy link

Hello, I would like to know if there is a way to implement with a little bit of source code change "lazy mixin call"
For such as:

index.pug

+addStyle("index") // Push into the styles array

doctype html 
html
    include include/header.pug // Will pull from the array
    body 
        include include/navbar.pug // Push into the array
        h1 Some Content

navbar.pug

head
    title My Page
    +getScripts()
    +getStyles()

Mixins.pug

mixin addStyle(stylePath)
    - template.addStyle(stylePath)

mixin getStyles()
    each stylePath in template.getStyles()
        link(rel="stylesheet" href=stylePath)

Inside my header.pug, I have a function that will transform all added styles into a proper format, the issue is that since the execution of the files are sequential, the navbar, footer (or any other addStyle down the line of the current index) will never be placed inside the header.

Is there a way to implement a "lazy" mixin call such as ~getStyles() that will be executed only at the end of the main execution, so all my addStyles will be registered and THEN the header will be properly populated with all the styles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant