Forked from tameemsafi/nunjucks-import-all-macros-into-a-global-variable.njk
Created
March 8, 2022 05:22
-
-
Save AdeptSEO/726f378a74fe6060d764c3382f2a89b3 to your computer and use it in GitHub Desktop.
Nunjucks - Import all macros into a global variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Import macros for global use in all views #} | |
{% set components = {} %} | |
{% for component in macroFilePaths %} | |
{% import component as temp %}{% set macro = _.assign(components, temp) %} | |
{% endfor %} | |
{# end #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment