This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #620 from lzhan/fixlinterr
fix issue #546 multiple jslint errors in developer-guide
- Loading branch information
Showing
87 changed files
with
1,428 additions
and
1,254 deletions.
There are no files selected for viewing
59 changes: 30 additions & 29 deletions
59
examples/developer-guide/adding_view_engines/addons/view-engines/ejs.server.js
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,33 +1,34 @@ | ||
YUI.add('addons-viewengine-ejs', function(Y, NAME) { | ||
/*jslint anon:true, sloppy:true, nomen:true, stupid:true*/ | ||
|
||
var ejs = require('ejs'), | ||
fs = require('fs'); | ||
function EjsAdapter(viewId) { | ||
this.viewId = viewId; | ||
} | ||
EjsAdapter.prototype = { | ||
YUI.add('addons-viewengine-ejs', function (Y, NAME) { | ||
|
||
render: function(data, mojitType, tmpl, adapter, meta, more) { | ||
var me = this, | ||
handleRender = function(output) { | ||
var ejs = require('ejs'), | ||
fs = require('fs'); | ||
function EjsAdapter(viewId) { | ||
this.viewId = viewId; | ||
} | ||
EjsAdapter.prototype = { | ||
|
||
output.addListener('data', function(c) { | ||
adapter.flush(c, meta); | ||
}); | ||
output.addListener('end', function() { | ||
if (!more) { | ||
adapter.done('', meta); | ||
} | ||
}); | ||
}; | ||
Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME); | ||
var result = ejs.render(this.compiler(tmpl),data); | ||
console.log(result); | ||
adapter.done(result,meta); | ||
}, | ||
compiler: function(tmpl) { | ||
return fs.readFileSync(tmpl, 'utf8'); | ||
} | ||
}; | ||
Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter; | ||
render: function (data, mojitType, tmpl, adapter, meta, more) { | ||
var me = this, | ||
handleRender = function (output) { | ||
output.addListener('data', function (c) { | ||
adapter.flush(c, meta); | ||
}); | ||
output.addListener('end', function () { | ||
if (!more) { | ||
adapter.done('', meta); | ||
} | ||
}); | ||
}, | ||
result = ejs.render(this.compiler(tmpl), data); | ||
Y.log('Rendering template "' + tmpl + '"', 'mojito', NAME); | ||
console.log(result); | ||
adapter.done(result, meta); | ||
}, | ||
compiler: function (tmpl) { | ||
return fs.readFileSync(tmpl, 'utf8'); | ||
} | ||
}; | ||
Y.namespace('mojito.addons.viewEngines').ejs = EjsAdapter; | ||
}, '0.1.0', {requires: []}); |
52 changes: 27 additions & 25 deletions
52
examples/developer-guide/adding_view_engines/mojits/myMojit/controller.server.js
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,28 +1,30 @@ | ||
YUI.add('myMojit', function(Y, NAME) { | ||
/*jslint anon:true, sloppy:true, nomen:true*/ | ||
|
||
Y.mojito.controllers[NAME] = { | ||
YUI.add('myMojit', function (Y, NAME) { | ||
|
||
init: function(config) { | ||
this.config = config; | ||
}, | ||
default_ve: function(ac) { | ||
ac.done({ | ||
"title": "Handlebars at work!", | ||
"view_engines": [ | ||
{"name": "EJS"}, | ||
{"name": "Jade"}, | ||
{"name": "dust"}, | ||
{"name": "underscore" } | ||
], | ||
"ul": { "title": 'Here are some of the other available rendering engines:' }, | ||
}); | ||
}, | ||
added_ve: function(ac) { | ||
ac.done({ | ||
"title": "EJS at work!", | ||
"view_engines": [ "Jade", "Dust","underscore" ], | ||
"ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' } | ||
}); | ||
} | ||
}; | ||
Y.mojito.controllers[NAME] = { | ||
|
||
init: function (config) { | ||
this.config = config; | ||
}, | ||
default_ve: function (ac) { | ||
ac.done({ | ||
"title": "Handlebars at work!", | ||
"view_engines": [ | ||
{"name": "EJS"}, | ||
{"name": "Jade"}, | ||
{"name": "dust"}, | ||
{"name": "underscore" } | ||
], | ||
"ul": { "title": 'Here are some of the other available rendering engines:' } | ||
}); | ||
}, | ||
added_ve: function (ac) { | ||
ac.done({ | ||
"title": "EJS at work!", | ||
"view_engines": [ "Jade", "Dust", "underscore" ], | ||
"ul": { "title": 'In addition to Handlebars and EJS, you can also use these rendering engines:' } | ||
}); | ||
} | ||
}; | ||
}, '0.0.1', {requires: ['mojito', 'myMojitModelFoo']}); |
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
Oops, something went wrong.