-
Notifications
You must be signed in to change notification settings - Fork 0
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 #46 from vimia/BL-23-2
BL-23 / BL-22 - EJS Filters + Moment.js DateFromNow filter!
- Loading branch information
Showing
6 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* View Filters | ||
* | ||
* @see https://github.com/vimia/blew/issues/23 | ||
*/ | ||
module.exports = { | ||
|
||
/** | ||
* Apply moment.js at server-side as a filter | ||
* | ||
* @param d - Dirty Date | ||
* @return 'x days ago' | ||
*/ | ||
dateFromNow: function(d) { | ||
var moment = require('moment'); | ||
return moment(d).fromNow(); | ||
} | ||
//TODO - Date Component creator.. | ||
} | ||
|
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,4 +1,12 @@ | ||
|
||
module.exports.bootstrap = function(cb) { | ||
cb(); | ||
|
||
/** | ||
* Injecting EJS Filters in the FilterService | ||
* | ||
* @see https://github.com/vimia/blew/issues/23 | ||
*/ | ||
sails.config.http.locals.filters = FilterService; | ||
_.extend(sails.hooks.http.app.locals, sails.config.http.locals); | ||
}; |
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
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