更新时间:2022-09-14 15:34:45
应用场景nodejs Express框架,使用art-template模板引擎。
后台注册方法代码:
1
2
3
4
|
var template = require( 'art-template' );
template.helper( 'myRegFunc' , function (str1, str2) {
return "我是后台方法: " + str1 + str2;
}); |
前台使用:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<! DOCTYPE html>
< html lang="en">
< head >
< meta charset="UTF-8">
< title ></ title >
< script type="application/javascript"></ script >
</ head >
< body >
{{myRegFunc "你好" "世界!"}} </ body >
</ html >
|
运行效果如图:
本文转自王磊的博客博客园博客,原文链接:http://www.cnblogs.com/vipstone/p/4868226.html,如需转载请自行联系原作者