question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nunjucks for js files

See original GitHub issue

In #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:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
probinscommented, Dec 20, 2020

Deno/Lume is way faster than Jekyll: the site I’m working on took several minutes with Jekyll, but <1 minute with Lume, and most of that is loading the Docker image.

just for interest, here’s a screenshot of recent commits to my site (>1300 pages). Spot the difference! Screenshot 2020-12-20 at 08 58 24

2reactions
probinscommented, Dec 19, 2020

yes, sorry, my bad. I had the js in a new dir, and forgot to copy _data over. Duh! Works fine, including layout: null. 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found