This repository has been archived by the owner on Apr 11, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f39a4b2
commit e16e78f
Showing
2 changed files
with
14 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
var testCase = require('nodeunit').testCase, | ||
swig = require('../../index'); | ||
var swig = require('../../index'); | ||
|
||
exports.filter = testCase({ | ||
setUp: function (callback) { | ||
describe('Tag: filter', function () { | ||
beforeEach(function () { | ||
swig.init({}); | ||
callback(); | ||
}, | ||
}); | ||
|
||
basic: function (test) { | ||
var tpl = swig.compile('{% filter capitalize %}oh HEY there{% endfilter %}'); | ||
test.strictEqual(tpl({}), 'Oh hey there'); | ||
test.done(); | ||
}, | ||
it('accepts a filter as an argument', function () { | ||
swig.compile('{% filter capitalize %}oh HEY there{% endfilter %}')({}).should.equal('Oh hey there'); | ||
}); | ||
|
||
'complex content': function (test) { | ||
it('works across complex content', function () { | ||
var tpl = swig.compile('{% filter capitalize %}oh {{ foo }} {% if here %}here{% else %}there{% endif %}{% endfilter %}'); | ||
test.strictEqual(tpl({ foo: 'HEY', here: true }), 'Oh hey here'); | ||
test.done(); | ||
}, | ||
tpl({ foo: 'HEY', here: true }).should.equal('Oh hey here'); | ||
}); | ||
|
||
args: function (test) { | ||
it('can accept arguments for the filter', function () { | ||
var tpl = swig.compile('{% filter replace "\\." "!" "g" %}hi. my name is paul.{% endfilter %}'); | ||
test.strictEqual(tpl({}), 'hi! my name is paul!'); | ||
test.done(); | ||
} | ||
tpl({}).should.equal('hi! my name is paul!'); | ||
}); | ||
}); |