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

Nunjuck plugin constructor options #90

Merged
merged 2 commits into from
May 3, 2021

Conversation

fserb
Copy link
Contributor

@fserb fserb commented May 2, 2021

This pipes the options from pluginOptions to the Nunjuck's environment constructor.

@oscarotero
Copy link
Member

Nunjucks is not using any option already, so this change doesn't have any effect.

@fserb
Copy link
Contributor Author

fserb commented May 2, 2021

I'm not sure what you mean. This allows the user to pass options to the nunjucks, like those:

const site = lume({ }, {
  nunjucks: {
    trimBlocks: true
  }
});

@oscarotero
Copy link
Member

Ah, got it. I see that you are passing the options in new nunjucks.Environment.

Ok, before merging, I propose two changes:

  1. The config object passed to plugins isn't only to configure nunjucks but the whole plugin. This includes the file extensions to which the plugin will be applied and opens the door to other future options. If you see other extensions like terser or markdown, there's a options key containing the options for the terser and markdown-it library. For nunjucks, we should do the same:
const site = lume({ }, {
  nunjucks: {
    options: {
      trimBlocks: true
    }
  }
});
  1. You're passing userOptions to NunjucksEngine instead the options variable (result of merging user and default options), and specifically, options.options (Only the options for the template engine): const nunjucksEngine = new NunjucksEngine(site, options.options);

@fserb
Copy link
Contributor Author

fserb commented May 3, 2021

Done. I think. As I understood both requests were kinda the same? Please let me know.

@oscarotero oscarotero merged commit 160bfaf into lumeland:master May 3, 2021
@oscarotero
Copy link
Member

Perfect. Thanks!

@fserb fserb deleted the nunjucks-options branch May 3, 2021 18:34
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

Successfully merging this pull request may close these issues.

2 participants