Skip to content
Browse files

Deleted bare controller template

Instead of having to seperate files the resource controller template uses a option called `bare` that
if false will render the other actions, and will only include the index action if true
  • Loading branch information...
1 parent 745c109 commit cf999eaa6d3d4e164158eac0923ad4e8fe9685db @larzconwell larzconwell committed
Showing with 6 additions and 17 deletions.
  1. +4 −3 templates/Jakefile
  2. +0 −12 templates/bare_controller.ejs
  3. +2 −2 templates/resource_controller.ejs
View
7 templates/Jakefile
@@ -18,12 +18,13 @@ namespace('gen', function () {
var names = _getInflections(name)
, text = fs.readFileSync(path.join(__dirname, filename + '.ejs'), 'utf8').toString()
+ , bare = options.bare || false // Default to full controller
, templ
, filePath;
// Render with the right model name
templ = new adapter({ data: {ext: '.ejs'}, text: text, templato: templato });
- templ.process({names: names});
+ templ.process({names: names, bare: bare});
// Write file
filePath = path.join('app', dirname, names.filename[options.inflection] + '.js');
@@ -102,7 +103,7 @@ namespace('gen', function () {
});
task('controller', [], function(name) {
- _writeTemplate(name, 'resource_controller', 'controllers', { inflection: 'plural' });
+ _writeTemplate(name, 'resource_controller', 'controllers', { inflection: 'plural', bare: false });
});
task('route', [], function(name, options) {
@@ -191,7 +192,7 @@ namespace('gen', function () {
});
task('bareController', [], function(name, engine) {
- _writeTemplate(name, 'bare_controller', 'controllers', { inflection: 'plural' });
+ _writeTemplate(name, 'resource_controller', 'controllers', { inflection: 'plural', bare: true });
jake.Task['gen:route'].invoke(name, { bare: true });
jake.Task['gen:views'].invoke(name, { bare: true, engine: engine });
View
12 templates/bare_controller.ejs
@@ -1,12 +0,0 @@
-
-var <%= names.constructor.plural %> = function () {
- this.respondsWith = ['html', 'json', 'xml', 'js', 'txt'];
-
- this.index = function (params) {
- this.respond({params: params});
- };
-
-};
-
-exports.<%= names.constructor.plural %> = <%= names.constructor.plural %>;
-
View
4 templates/resource_controller.ejs
@@ -5,7 +5,7 @@ var <%= names.constructor.plural %> = function () {
this.index = function (req, resp, params) {
this.respond({params: params});
};
-
+<% if(!bare) { %>
this.add = function (req, resp, params) {
this.respond({params: params});
};
@@ -31,7 +31,7 @@ var <%= names.constructor.plural %> = function () {
this.remove = function (req, resp, params) {
this.respond({params: params});
};
-
+<% } %>
};
exports.<%= names.constructor.plural %> = <%= names.constructor.plural %>;

0 comments on commit cf999ea

Please sign in to comment.
Something went wrong with that request. Please try again.