mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
Merge pull request #250 from jsumners/missing-global
Make renderSync behave if no context was supplied
This commit is contained in:
commit
f878db5545
@ -103,15 +103,16 @@ Template.prototype = {
|
||||
this._ = createFunc(helpers);
|
||||
},
|
||||
renderSync: function(data) {
|
||||
var localData = data || {};
|
||||
var out = new AsyncWriter();
|
||||
out.sync();
|
||||
|
||||
if (data.$global) {
|
||||
out.global = extend(out.global, data.$global);
|
||||
delete data.$global;
|
||||
if (localData.$global) {
|
||||
out.global = extend(out.global, localData.$global);
|
||||
delete localData.$global;
|
||||
}
|
||||
|
||||
this._(data, out);
|
||||
this._(localData, out);
|
||||
return out.getOutput();
|
||||
},
|
||||
|
||||
|
||||
@ -256,6 +256,13 @@ describe('api' , function() {
|
||||
expect(e).to.not.equal(undefined);
|
||||
});
|
||||
|
||||
it('should handle no context passed to renderSync', function() {
|
||||
var template = marko.load(nodePath.join(__dirname, 'fixtures/api-tests/hello-empty.marko'));
|
||||
var output = template.renderSync();
|
||||
|
||||
expect(output).to.equal('Hello!');
|
||||
});
|
||||
|
||||
it('should allow a template to be loaded from a compiled JS module', function(done) {
|
||||
// Load the JS file to ensure the hello.marko.js file is created
|
||||
marko.load(nodePath.join(__dirname, 'fixtures/api-tests/hello.marko'));
|
||||
|
||||
1
test/fixtures/api-tests/hello-empty.marko
vendored
Normal file
1
test/fixtures/api-tests/hello-empty.marko
vendored
Normal file
@ -0,0 +1 @@
|
||||
- Hello!
|
||||
Loading…
x
Reference in New Issue
Block a user