Permalink
Browse files

fix many bugs that came up during testing, update changelog, mark 1.0

  • Loading branch information...
1 parent 1aa3f87 commit b0330e04ac6aa585ae4fd1338183687af9284bfd @jlongster committed Oct 24, 2013
View
@@ -1,14 +1,38 @@
Changelog for versions previous to v0.1.9 are located at http://nunjucks.tumblr.com/.
-# v0.9.0 (August ?, 2013)
+# v1.0.0 (October 24, 2013)
-* API is now async, and async filters and loaders is supported. sync API should still work.
-* Much simpler higher-level API for initiating/configuring nunjucks is available
-* Express integration is much simpler and better
+We've hit 1.0! Thanks for helping nunjucks stabilize and become
+awesome. I've added many good features recently and several people
+have been using them, and everything seems stable. I think it's time
+to cut 1.0.
-TODO:
+## Big changes:
-* make grunt task after 0.9.0 release
+* An asynchronous API is now available, and async filters, extensions, and
+ loaders is supported. The async API is optional and if you don't do
+ anything async (the default), nothing changes for you. You can read
+ more about this
+ [here](http://jlongster.github.io/nunjucks/api.html#asynchronous-support). (fixes #41)
+* Much simpler higher-level API for initiating/configuring nunjucks is
+ available. Read more
+ [here](http://jlongster.github.io/nunjucks/api.html#simple-api).
+* An official grunt plugin is available for precompiling templates: [grunt-nunjucks](https://github.com/jlongster/grunt-nunjucks)
+* **The browser files have been renamed**. nunjucks.js is now the full
+ library with compiler, and nunjucks-slim.js is the small version
+ that only works with precompiled templates
+
+## Smaller changes:
+
+* urlencode filter has been added
+* The express integration has been refactored and isn't a kludge
+ anymore. Should avoid some bugs and be more future-proof;
+* The order in which variables are lookup up in the context and frame
+ lookup has been reversed. It will now look in the frame first, and
+ then the context. This means that if a `for` loop introduces a new
+ var, like `{% for name in names %}`, and if you have `name` in the
+ context as well, it will properly reference `name` from the for loop
+ inside the loop. (fixes #122 and #119)
# v0.1.10 (August 9, 2013)
View
@@ -1,8 +1,10 @@
#!/bin/sh
ROOT=`dirname "$0"`
-output="$1"
+VERSION=`node -e "var fs = require('fs'); var p = JSON.parse(fs.readFileSync('./package.json')); console.log(p.version)"`
+TYPE=""
+output="$1"
if [ -z "$SLIM" ]; then
# Listed in order of dependency
files="object.js lib.js nodes.js runtime.js lexer.js parser.js transformer.js
@@ -12,10 +14,12 @@ else
# Listed in order of dependency
files="object.js lib.js runtime.js loader.js web-loaders.js loaders.js filters.js
globals.js environment.js"
+ TYPE="(slim, only works with precompiled templates)"
fi
rm -f "$output"
+echo "// Browser bundle of nunjucks $VERSION $TYPE\n" >> "$output"
echo "(function() {" >> "$output"
echo "var modules = {};" >> "$output"
View
@@ -44,7 +44,7 @@ if (argv.help) {
var env = new Environment([]);
lib.each([].concat(argv.filters).join(',').split(','), function(name) {
- env.addFilter(name, function() {}, true);
+ env.addFilter(name.trim(), function() {}, true);
});
console.log(precompile(argv._[0], {
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,3 +1,5 @@
+// Browser bundle of nunjucks 1.0.0 (slim, only works with precompiled templates)
+
(function() {
var modules = {};
(function() {
@@ -1458,9 +1460,12 @@ var Environment = Obj.extend({
var syncResult = null;
this.getTemplate(name, function(err, tmpl) {
- if(err) {
+ if(err && cb) {
cb(err);
}
+ else if(err) {
+ throw err;
+ }
else {
tmpl.render(ctx, cb || function(err, res) {
if(err) { throw err; }
@@ -1765,8 +1770,10 @@ nunjucks.renderString = function(src, ctx, cb) {
return e.renderString(src, ctx, cb);
};
-nunjucks.precompile = precompile.precompile;
-nunjucks.precompileString = precompile.precompileString;
+if(precompile) {
+ nunjucks.precompile = precompile.precompile;
+ nunjucks.precompileString = precompile.precompileString;
+}
nunjucks.require = function(name) { return modules[name]; };

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,3 +1,5 @@
+// Browser bundle of nunjucks 1.0.0
+
(function() {
var modules = {};
(function() {
@@ -2611,8 +2613,9 @@ function _liftFilters(node, asyncFilters, prop) {
if(node instanceof nodes.Block) {
return node;
}
- else if(node instanceof nodes.Filter &&
- asyncFilters.indexOf(node.name.value) !== -1) {
+ else if((node instanceof nodes.Filter &&
+ asyncFilters.indexOf(node.name.value) !== -1) ||
+ node instanceof nodes.CallExtensionAsync) {
var symbol = new nodes.Symbol(node.lineno,
node.colno,
gensym());
@@ -4629,9 +4632,12 @@ var Environment = Obj.extend({
var syncResult = null;
this.getTemplate(name, function(err, tmpl) {
- if(err) {
+ if(err && cb) {
cb(err);
}
+ else if(err) {
+ throw err;
+ }
else {
tmpl.render(ctx, cb || function(err, res) {
if(err) { throw err; }
@@ -4936,8 +4942,10 @@ nunjucks.renderString = function(src, ctx, cb) {
return e.renderString(src, ctx, cb);
};
-nunjucks.precompile = precompile.precompile;
-nunjucks.precompileString = precompile.precompileString;
+if(precompile) {
+ nunjucks.precompile = precompile.precompile;
+ nunjucks.precompileString = precompile.precompileString;
+}
nunjucks.require = function(name) { return modules[name]; };
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -58,5 +58,7 @@ module.exports.renderString = function(src, ctx, cb) {
return e.renderString(src, ctx, cb);
};
-module.exports.precompile = precompile.precompile;
-module.exports.precompileString = precompile.precompileString;
+if(precompile) {
+ module.exports.precompile = precompile.precompile;
+ module.exports.precompileString = precompile.precompileString;
+}
View
@@ -1,7 +1,7 @@
{
"name": "nunjucks",
"description": "A jinja inspired templating engine",
- "version": "0.1.10",
+ "version": "1.0.0",
"author": {
"name": "James Long",
"email": "longster@gmail.com"
View
@@ -201,9 +201,12 @@ var Environment = Obj.extend({
var syncResult = null;
this.getTemplate(name, function(err, tmpl) {
- if(err) {
+ if(err && cb) {
cb(err);
}
+ else if(err) {
+ throw err;
+ }
else {
tmpl.render(ctx, cb || function(err, res) {
if(err) { throw err; }
View
@@ -23,12 +23,14 @@ var FileSystemLoader = Loader.extend({
// Watch all the templates in the paths and fire an event when
// they change
lib.each(this.searchPaths, function(p) {
- fs.watch(p, { persistent: false }, function(event, filename) {
- var fullname = path.join(p, filename);
- if(event == 'change' && fullname in this.pathsToNames) {
- this.emit('update', this.pathsToNames[fullname]);
- }
- }.bind(this));
+ if(existsSync(p)) {
+ fs.watch(p, { persistent: false }, function(event, filename) {
+ var fullname = path.join(p, filename);
+ if(event == 'change' && fullname in this.pathsToNames) {
+ this.emit('update', this.pathsToNames[fullname]);
+ }
+ }.bind(this));
+ }
}.bind(this));
}
},
@@ -39,7 +41,11 @@ var FileSystemLoader = Loader.extend({
for(var i=0; i<paths.length; i++) {
var p = path.join(paths[i], name);
- if(p.indexOf(paths[i]) === 0 && existsSync(p)) {
+
+ // Only allow the current directory and anything
+ // underneath it to be searched
+ if((paths[i] == '.' || p.indexOf(paths[i]) === 0) &&
+ existsSync(p)) {
fullpath = p;
break;
}
View
@@ -12,6 +12,7 @@ function match(filename, patterns) {
}
function precompileString(str, opts) {
+ opts = opts || {};
opts.isString = true;
return precompile(str, opts);
}
@@ -48,7 +49,7 @@ function precompile(input, opts) {
}
else if(pathStats.isFile()) {
return _precompile(fs.readFileSync(input, 'utf-8'),
- opts.name || input,
+ opts.name || input,
env,
opts.asFunction);
}
View
@@ -92,8 +92,9 @@ function _liftFilters(node, asyncFilters, prop) {
if(node instanceof nodes.Block) {
return node;
}
- else if(node instanceof nodes.Filter &&
- asyncFilters.indexOf(node.name.value) !== -1) {
+ else if((node instanceof nodes.Filter &&
+ asyncFilters.indexOf(node.name.value) !== -1) ||
+ node instanceof nodes.CallExtensionAsync) {
var symbol = new nodes.Symbol(node.lineno,
node.colno,
gensym());
View
@@ -14,7 +14,7 @@
mocha.setup('bdd');
</script>
- <script src="../../browser/nunjucks-dev.js"></script>
+ <script src="../../nunjucks.js"></script>
<script src="../util.js"></script>
<script src="../lexer.js"></script>

0 comments on commit b0330e0

Please sign in to comment.