Skip to content

Commit

Permalink
Adds middleware-based template compilation
Browse files Browse the repository at this point in the history
when no task-runner is used
  • Loading branch information
Léo-Paul COUTURIER committed Jul 25, 2014
1 parent 9cb7ccb commit 20d67c3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
24 changes: 23 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ inquirer.prompt([{
info.dependencies.express = '*';

// main.js
copy(path.join(__dirname, 'templates', 'main.js'), path.join(directory, 'main.js'));
parseTemplate(path.join(__dirname, 'templates', 'main.js'), path.join(directory, 'main.js'), answers);
} else {
// index.php
parseTemplate(path.join(__dirname, 'templates', 'index.html'), path.join(directory, 'index.php'), answers);
Expand Down Expand Up @@ -253,6 +253,28 @@ inquirer.prompt([{

// Gruntfile
parseTemplate(path.join(__dirname, 'templates', 'Gruntfile.js'), path.join(directory, 'Gruntfile.js'), answers);
} else {
switch(answers.htmlTemplate) {
case 'Jade':
info.dependencies['connect-jade-html'] = '*';
break;
case 'EJS':
info.dependencies['ejs-middleware'] = '*';
}
switch(answers.cssTemplate) {
case 'Sass':
info.dependencies['sass-middleware'] = '*';
break;
case 'Less':
info.dependencies['less-middleware'] = '*';
break;
case 'Stylus':
info.dependencies['stylus'] = '*';
}
switch(answers.jsTemplate) {
case 'Coffee':
info.dependencies['coffee-middleware'] = '*';
}
}

// Procfile
Expand Down
34 changes: 34 additions & 0 deletions templates/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
var express = require('express'),
<% if(data.taskRunner === 'None') { %>
<% if(data.htmlTemplate === 'Jade') { %>
jade = require('connect-jade-html'),
<% } else if(data.htmlTemplate === 'EJS') { %>
ejs = require('ejs-middleware'),
<% } %>
<% if(data.cssTemplate === 'Sass') { %>
sass = require('sass-middleware'),
<% } else if(data.cssTemplate === 'Less') { %>
less = require('less-middleware'),
<% } else if(data.cssTemplate === 'Stylus') { %>
stylus = require('stylus'),
<% } %>
<% if(data.jsTemplate !== 'JS') { %>
coffee = require('coffee-middleware'),
<% } %>
<% } %>
app = express();

<% if(data.taskRunner === 'None') { %>
<% if(data.htmlTemplate === 'Jade') { %>
app.use(jade({src: __dirname + '/dist'}));
<% } else if(data.htmlTemplate === 'EJS') { %>
app.use(ejs(__dirname + '/dist'));
<% } %>
<% if(data.cssTemplate === 'Sass') { %>
app.use(sass({src: __dirname + '/dist'}));
<% } else if(data.cssTemplate === 'Less') { %>
app.use(less(__dirname + '/dist'));
<% } else if(data.cssTemplate === 'Stylus') { %>
app.use(stylus.middleware(__dirname + '/dist'));
<% } %>
<% if(data.jsTemplate !== 'JS') { %>
app.use(coffee({src: __dirname + '/dist'}));
<% } %>
<% } %>
app.use(express.static(__dirname + '/dist'));

var port = process.env.PORT || 3000,
Expand Down

0 comments on commit 20d67c3

Please # to comment.