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

Add chaining of env 'add' methods #537

Merged
merged 1 commit into from
Oct 2, 2015
Merged

Conversation

robgraeber
Copy link
Contributor

As discussed in #485, adds chaining for env 'add' methods like addGlobal, addFilter, addBlock, etc. I also wrote a test for addGlobal chaining and verified all the tests still pass. Let me know if you want anything improved.

@devoidfury @jlongster @carljm

This would make chaining like this 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'
});

@carljm
Copy link
Contributor

carljm commented Oct 1, 2015

Thanks @robgraeber ! Mind adding an entry to the changelog for this? Also, do you think this is worth mentioning in the documentation for those methods?

@robgraeber robgraeber force-pushed the master branch 2 times, most recently from f36a63a to cfb0a52 Compare October 2, 2015 07:01
@robgraeber
Copy link
Contributor Author

Hey @carljm sure, updated the changelog and made references in the docs. I think mentioning those functions have a return value now could be nice.

carljm added a commit that referenced this pull request Oct 2, 2015
Add chaining of env 'add' methods
@carljm carljm merged commit 17bdf4c into mozilla:master Oct 2, 2015
@carljm
Copy link
Contributor

carljm commented Oct 2, 2015

Merged, thanks for the contribution!

carljm added a commit that referenced this pull request Oct 2, 2015
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.

None yet

2 participants