Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge branch 'tvavrys-master'. Closes gh-407
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Jan 28, 2014
2 parents 8cd0f2f + 50358d7 commit 0ae0987
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tags/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports.compile = function (compiler, args) {
var file = args.shift(),
onlyIdx = args.indexOf(only),
onlyCtx = onlyIdx !== -1 ? args.splice(onlyIdx, 1) : false,
parentFile = args.pop().replace(/\\/g, '\\\\'),
parentFile = (args.pop() || '').replace(/\\/g, '\\\\'),
ignore = args[args.length - 1] === missing ? (args.pop()) : false,
w = args.join('');

Expand Down
5 changes: 5 additions & 0 deletions tests/tags/include.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ var swig = require('../../lib/swig'),
expect = require('expect.js');

describe('Tag: include', function () {
it('Works with non-relative loader setups', function () {
var s = new swig.Swig({ loader: swig.loaders.memory({ '/foo/foobar': 'tacos!' }, '/foo')});
expect(s.render('{% include "foobar" %}')).to.equal('tacos!');
});

describe('{% include "foo" ignore missing %}', function () {
it('does not throw if missing', function () {
expect(swig.render('{% include "foo" ignore missing %}', { filename: '/foo' }))
Expand Down

0 comments on commit 0ae0987

Please sign in to comment.