1 | (function() {
|
2 | var expect, Environment, Loader, templatesPath;
|
3 |
|
4 | if(typeof require != 'undefined') {
|
5 | expect = require('expect.js');
|
6 | Environment = require('../src/environment').Environment;
|
7 | templatesPath = 'tests/templates';
|
8 | }
|
9 | else {
|
10 | expect = window.expect;
|
11 | Environment = nunjucks.Environment;
|
12 | Loader = nunjucks.WebLoader;
|
13 | templatesPath = '../templates';
|
14 | }
|
15 |
|
16 | describe('loader', function() {
|
17 | it('should allow a simple loader to be created', function() {
|
18 |
|
19 |
|
20 | function MyLoader(opts) {
|
21 |
|
22 | }
|
23 |
|
24 | MyLoader.prototype.getSource = function(name) {
|
25 | return { src: "Hello World",
|
26 | path: "/tmp/somewhere" };
|
27 | };
|
28 |
|
29 | var env = new Environment(new MyLoader(templatesPath));
|
30 | var parent = env.getTemplate('fake.html');
|
31 | expect(parent.render()).to.be('Hello World');
|
32 | });
|
33 | });
|
34 | })();
|