add condition if in handlebars helper
Showing
1 changed file
with
20 additions
and
5 deletions
@@ -11,11 +11,11 @@ const config = require('../config/common'); | @@ -11,11 +11,11 @@ const config = require('../config/common'); | ||
11 | 11 | ||
12 | /** | 12 | /** |
13 | * 七牛图片路径处理 | 13 | * 七牛图片路径处理 |
14 | - * @param {[tring]} url | ||
15 | - * @param {[tring]} width | ||
16 | - * @param {[tring]} height | ||
17 | - * @param {[tring]} mode | ||
18 | - * @return {[tring]} | 14 | + * @param {[string]} url |
15 | + * @param {[string]} width | ||
16 | + * @param {[string]} height | ||
17 | + * @param {[string]} mode | ||
18 | + * @return {[string]} | ||
19 | */ | 19 | */ |
20 | exports.image = (url, width, height, mode) => { | 20 | exports.image = (url, width, height, mode) => { |
21 | mode = _.isNumber(mode) ? mode : 2; | 21 | mode = _.isNumber(mode) ? mode : 2; |
@@ -24,6 +24,21 @@ exports.image = (url, width, height, mode) => { | @@ -24,6 +24,21 @@ exports.image = (url, width, height, mode) => { | ||
24 | }; | 24 | }; |
25 | 25 | ||
26 | /** | 26 | /** |
27 | + * 条件判断 | ||
28 | + * @param {[string]} v1 | ||
29 | + * @param {[string]} v2 | ||
30 | + * @param {[object]} options 上下文环境,一般不手动传 | ||
31 | + * @return {[boolen]} | ||
32 | + */ | ||
33 | +exports.ifEqualTo = (v1, v2, _options) => { | ||
34 | + if (v1 === v2) { | ||
35 | + return _options.fn(this); // eslint-disable-line | ||
36 | + } | ||
37 | + | ||
38 | + return _options.inverse(this); // eslint-disable-line | ||
39 | +}; | ||
40 | + | ||
41 | +/** | ||
27 | * 站内地址格式化 | 42 | * 站内地址格式化 |
28 | * @param {[string]} uri 路径 | 43 | * @param {[string]} uri 路径 |
29 | * @param {[object]} qs 查询字符串 | 44 | * @param {[object]} qs 查询字符串 |
-
Please register or login to post a comment