Nunjucks for js files
See original GitHub issueIn #11, I mentioned being able to use templates with js files, so I can for example populate an array from shared data. You can do this In Jekyll (and can define layout: null
for non-html files). I hoped that if I specified a _data.json
with templateEngine: njk
it would work, but it ignores the directory. If I rename the js file to *.njk
, then it creates an output html, but doesn’t parse the templates.
In the particular case I’m working on, I can get around this by including the js in the html file, but that’s not very efficient if I have several html pages that use the same js.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Nunjucks
Rich Powerful language with block inheritance, autoescaping, macros, asynchronous control, and more. Heavily inspired by jinja2; Fast & Lean High-performant ...
Read more >How to use JavaScript code inside templates? #655 - GitHub
I was wondering whether there is a way to manipulate the template using JavaScript functions or statements inside nunjucks templating.
Read more >Template Language—Nunjucks — Eleventy
Nunjucks provides a custom way to add globals to templates. These can be any arbitrary JavaScript: functions, variables, etc. Note that this is...
Read more >How to add page specific scripts using nunjucks and express ...
I have tried to use express locals for passing in the page title and sending the array of common scripts + home.js but...
Read more >nunjucks-to-html - npm
Keep your HTML clean and modularized by using a templating engine, like Nunjucks. Then, convert those files into HTML during your development ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
just for interest, here’s a screenshot of recent commits to my site (>1300 pages). Spot the difference!
yes, sorry, my bad. I had the js in a new dir, and forgot to copy
_data
over. Duh! Works fine, includinglayout: null
. 👍