在胡子javascript中使用参数调用函数 [英] calling function with arguments in mustache javascript

查看:125
本文介绍了在胡子javascript中使用参数调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Mustache.js 调用带参数的函数

 
{{somefunction(somevalue)}}


谢谢

解决方案

查看有关Lambdas的部分,请访问 http://mustache.github.com/mustache.5.html



小胡子模板块:

  {{# someFunction}} someValue {{/ someFunction}} 

功能块:

  someFunction:function(){
return function(val,render){
return我传入了这个值:+ render( VAL);
};
}

输出:

 我传递了这个值:someValue 


Is it possible to call a function with arguments with Mustache.js

{{somefunction(somevalue)}}
thank you

解决方案

Check out the section on Lambdas at http://mustache.github.com/mustache.5.html

Mustache template block:

{{#someFunction}}someValue{{/someFunction}}

Function block:

someFunction : function () {
  return function(val, render) {
    return "I passed in this value: " + render(val);
  };
}

Output:

I passed in this value: someValue

这篇关于在胡子javascript中使用参数调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆