Authored by 毕凯

增加七牛 helper

... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: 'helpers'
helpers: require('../../library/helpers')
}));
// router
... ...
<div class="icons-wrapper">
<ul class="icons-list clearfix">
{{#appIconList}}
<li class="icons-item"><a href="{{url}}" class="imagebar"><img src="{{src}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li>
<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>
{{/appIconList}}
</ul>
</div>
... ...
/**
* Handlebars helpers
* bikai kai.bi@yoho.cn
* 2016-05-10
*/
var _ = require('lodash');
/**
* 七牛图片路径处理
* @param {[tring]} url
* @param {[tring]} width
* @param {[tring]} height
* @param {[tring]} mode
* @return {[tring]}
*/
exports.image = function(url, width, height, mode) {
mode = _.isNumber(mode) ? mode : 1;
return url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode);
};
... ...