Showing
3 changed files
with
22 additions
and
2 deletions
@@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ | @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ | ||
24 | defaultLayout: 'layout', | 24 | defaultLayout: 'layout', |
25 | layoutsDir: doraemon, | 25 | layoutsDir: doraemon, |
26 | partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], | 26 | partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], |
27 | - helpers: 'helpers' | 27 | + helpers: require('../../library/helpers') |
28 | })); | 28 | })); |
29 | 29 | ||
30 | // router | 30 | // router |
1 | <div class="icons-wrapper"> | 1 | <div class="icons-wrapper"> |
2 | <ul class="icons-list clearfix"> | 2 | <ul class="icons-list clearfix"> |
3 | {{#appIconList}} | 3 | {{#appIconList}} |
4 | - <li class="icons-item"><a href="{{url}}" class="imagebar"><img src="{{src}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li> | 4 | + <li class="icons-item"><a href="{{url}}" class="imagebar"><img src="{{image src 50 50}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li> |
5 | {{/appIconList}} | 5 | {{/appIconList}} |
6 | </ul> | 6 | </ul> |
7 | </div> | 7 | </div> |
library/helpers.js
0 → 100644
1 | +/** | ||
2 | + * Handlebars helpers | ||
3 | + * bikai kai.bi@yoho.cn | ||
4 | + * 2016-05-10 | ||
5 | + */ | ||
6 | + | ||
7 | +var _ = require('lodash'); | ||
8 | + | ||
9 | +/** | ||
10 | + * 七牛图片路径处理 | ||
11 | + * @param {[tring]} url | ||
12 | + * @param {[tring]} width | ||
13 | + * @param {[tring]} height | ||
14 | + * @param {[tring]} mode | ||
15 | + * @return {[tring]} | ||
16 | + */ | ||
17 | +exports.image = function(url, width, height, mode) { | ||
18 | + mode = _.isNumber(mode) ? mode : 1; | ||
19 | + return url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode); | ||
20 | +}; |
-
Please register or login to post a comment