11ty / 11ty/docs

Nunjucks own environment watching

Open
#246 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Nunjucks
Stars
547
Forks
726
Avg merge
2h 23m
Merged PRs (30d)
3

Description

While I realise that the example given in the docs for passing in your own instance of a Nunjucks Environment is purely illustrational, I spotted it as the solution for trimming down my {% include long/path/goes/here.html %} paths.

What I didn't realise (until I delved into the very sensibly linked docs) is that any changes to files in this path are not reflected when Eleventy spots a change unless the optional watch property is set to true.

Might I suggest a small change?

  let env = process.env.ELEVENTY_ENV;

  let nunjucksEnvironment = new Nunjucks.Environment(
    new Nunjucks.FileSystemLoader("_includes", {
      watch: env == "development"
    })
  );

Happy to submit a pull request if this might be a good idea.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Find the documentation example showing a custom Nunjucks Environment and its FileSystemLoader for Eleventy includes. Review the linked Nunjucks loader documentation first, then update the example to enable watching in development; done means the example reflects the suggested watch behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.