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

Nunjucks 2.0 TypeError when creating new Environment() in browser #523

Closed
jamie-pate opened this issue Sep 18, 2015 · 5 comments
Closed

Comments

@jamie-pate
Copy link

Looks like Nunjucks 2.0 is unusable in a web browser without configuration. If it's not meant to be useable, this situation should throw a custom error message instead, indicating the issue.

The webloader doesn't check to see if the opts argument has been provided (i guess it's not optional?)

    var WebLoader = Loader.extend({
        init: function(baseURL, opts) {
            this.baseURL = baseURL || '.';

            // By default, the cache is turned off because there's no way
            // to "watch" templates over HTTP, so they are re-downloaded
            // and compiled each time. (Remember, PRECOMPILE YOUR
            // TEMPLATES in production!)
            this.useCache = opts.useCache;

            // We default `async` to false so that the simple synchronous
            // API can be used when you aren't doing anything async in
            // your templates (which is most of the time). This performs a
            // sync ajax request, but that's ok because it should *only*
            // happen in development. PRECOMPILE YOUR TEMPLATES.
            this.async = opts.async;
        },

but when calling new Environment(), a new WebLoader is created without the opt argument.

                    this.loaders = [new builtin_loaders.WebLoader('/views')];
@carljm
Copy link
Contributor

carljm commented Sep 18, 2015

Thanks for the report, but I think this is a duplicate of #517, no?

@carljm carljm closed this as completed Sep 18, 2015
@jamie-pate
Copy link
Author

sorry, i searched but didn't see that

@jamie-pate
Copy link
Author

Also, feel mine's a bit more searchable ;) so at least i'm helping a bit!

@carljm
Copy link
Contributor

carljm commented Sep 18, 2015

Yep, no worries! Yours also provides more details.

@jgerigmeyer
Copy link
Contributor

Fixed in #524.

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

No branches or pull requests

3 participants