-
Notifications
You must be signed in to change notification settings - Fork 0
/
hbsHelpers.js
47 lines (31 loc) · 1.01 KB
/
hbsHelpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
var moment = require('helper-moment', {locale: 'kr'});
var markdown = require('markdown').markdown;
var Board = require('./models/board');
module.exports = exports = {
'moment' : moment,
'ifAdmin': function(user, options) {
var fnTrue = options.fn,
fnFalse = options.inverse;
return user && user.isAdmin ? fnTrue(this) : fnFalse(this);
},
'ifUser': function(user, options) {
var fnTrue = options.fn,
fnFalse = options.inverse;
return user && user.role == 'user' ? fnTrue(this) : fnFalse(this);
},
'ifGuest': function(user, options) {
var fnTrue = options.fn,
fnFalse = options.inverse;
return user && user.role == 'guest' ? fnTrue(this) : fnFalse(this);
},
'section': function(name, options){
if(!this._sections) this._sections = {};
this._sections[name] = options.fn(this);
return null;
},
'markdownToHtml': function(text, options){
return markdown.toHTML(text);
},
'topicToText': Board.menuToText
};