-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.coffee
32 lines (25 loc) · 967 Bytes
/
index.coffee
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
require 'coffee-script/register'
fs = require 'fs'
marked = require 'marked'
Handlebars = require 'handlebars'
Handlebars.registerHelper 'md', marked
Handlebars.registerHelper 'logo', (text) ->
return 'fa-github-square' if text == 'Github'
return 'fa-twitter-square' if text == 'Twitter'
return 'fa-envelope-square' if text == 'Email'
Handlebars.registerHelper 'truncate', (str, len) ->
if str && str.length > len
new Handlebars.SafeString(str.substring(0, len-3).concat('...'))
else
str
renderProfile = (profile) -> render 'profile', profile
renderPortfolio = (portfolio) -> render 'portfolio', portfolio
render= (name, model) ->
css = fs.readFileSync "#{__dirname}/style.css", 'utf-8'
template = fs.readFileSync "#{__dirname}/#{name}.template", 'utf-8'
options = css: css
options[name] = model
Handlebars.compile(template)(options)
module.exports =
renderProfile: renderProfile
renderPortfolio: renderPortfolio