Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved helpers to separate file

  • Loading branch information...
commit c918d07560edbac01a158363aef094ebf0aac924 1 parent ad9462a
@mattiasottosson authored
Showing with 24 additions and 24 deletions.
  1. +4 −24 app.js
  2. +20 −0 helpers/helpers.js
View
28 app.js
@@ -8,9 +8,6 @@ var express = require('express');
var app = module.exports = express.createServer();
appPath = __dirname;
-// Added controller
-require(appPath+'/controllers/index.js');
-
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
@@ -22,29 +19,12 @@ app.configure(function(){
app.use(express.static(__dirname + '/public'));
});
-// Ejs Helpers
-app.helpers({
-
- daysLeft: function(endDate) {
- var diff = new Date(endDate) - new Date();
- var days = Math.floor(diff/1000/3600/24+1);
- if(days < 0) {
- return {className: 'days-0', text: '0 dagar kvar'}
- }
-
- switch (days) {
- case 0:
- return {className: 'days-0', text: '0 dagar kvar'}
- case 1:
- return {className: 'days-1', text: '1 dag kvar'}
- default:
- return {className: 'days-'+days, text: days+' dagar kvar'}
- }
- }
-
-});
+// Load helpers
+app.helpers(require('./helpers/helpers.js'));
+// Load controller
+require(appPath+'/controllers/index.js');
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
View
20 helpers/helpers.js
@@ -0,0 +1,20 @@
+function daysLeft(endDate) {
+ var diff = new Date(endDate) - new Date();
+ var days = Math.floor(diff/1000/3600/24+1);
+
+ if(days < 0) {
+ return {className: 'days-0', text: '0 dagar kvar'}
+ }
+
+ switch (days) {
+ case 0:
+ return {className: 'days-0', text: '0 dagar kvar'}
+ case 1:
+ return {className: 'days-1', text: '1 dag kvar'}
+ default:
+ return {className: 'days-'+days, text: days+' dagar kvar'}
+ }
+}
+
+exports.daysLeft = daysLeft;
+
Please sign in to comment.
Something went wrong with that request. Please try again.