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

Env add functions should ideally return env object #485

Closed
robgraeber opened this issue Jul 29, 2015 · 2 comments
Closed

Env add functions should ideally return env object #485

robgraeber opened this issue Jul 29, 2015 · 2 comments

Comments

@robgraeber
Copy link
Contributor

Sometimes when configuring Nunjucks I want to just chain the addFilter / addGlobal functions etc. Does anyone else think it would make sense if addFilter / addGlobal would return the env object?

So code like this would be possible:

Nunjucks.configure(templateDir, {
    autoescape: true,
    trimBlocks: true,
    lstripBlocks: true,
    express: app
}).addGlobal('func1', function(arg) {
    return 'asdf'
}).addGlobal('func2', function(arg) {
    return 'asdf'
}).addGlobal('func3', function(arg) {
    return 'asdf'
}).addGlobal('func4', function(arg) {
    return 'asdf'
});

I could do the PR if others thought it was a good idea. These are the functions I was thinking of making chainable:

addFilter
addGlobal
addBlock
addExtension
express
@devoidfury
Copy link
Contributor

Yes, this would be a nice touch, I agree.

@jlongster
Copy link
Contributor

Works for me, feel free to open a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants