应用场景nodejs Express框架,使用art-template模板引擎。

后台注册方法代码:

var template = require('art-template');
template.helper('myRegFunc', function (str1, str2) {
return "我是后台方法: " + str1 + str2;
});

前台使用:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="application/javascript"></script>
</head>
<body> {{myRegFunc "你好" "世界!"}} </body>
</html>

运行效果如图:

art-template用户注册方法的更多相关文章

  1. art template前端模板引擎

    偶然看到后台有一段代码 采用的是art template的模板引擎 地址为 http://aui.github.io/artTemplate/ 这段代码很简洁 var html = template( ...

  2. JavaScript模板引擎artTemplate.js——template.helper()方法

    上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...

  3. JavaScript模板引擎artTemplate.js——template.compile()方法

    template.compile(source, options) source:必传,渲染模板的内容. options:可选,通常不传.(其实是我还没研究明白) return:一个渲染函数. 示例如 ...

  4. template.helper()方法

    上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...

  5. template.compile()方法

    template.compile(source, options) source:必传,渲染模板的内容. options:可选,通常不传.(其实是我还没研究明白) return:一个渲染函数. 示例如 ...

  6. art.template 循环里面分组。

    后台提供给我们一个数组,我们要用模版实现上面的格式输出怎么版呢? 下面就是解决方案: <h2>循环4个一组</h2> <script type="text/ht ...

  7. js template实现方法

    <script type="text/html" id="template"> <li class="list-item" ...

  8. 利用art.template模仿VUE 一次渲染多个模版

    TypeScript代码 import template = require('art-template/lib/template-web'); interface TemplateBindConfi ...

  9. 利用art.template模仿VUE

    首先先看一下Typescript代码: import template = require('art-template/lib/template-web'); interface TemplateBi ...

随机推荐

  1. [转载]iOS9 使用CoreLocation

    在iOS8之前,只要 #import <CoreLocation/CoreLocation.h>引入CoreLocation.framework. @property (nonatomic ...

  2. bzoj 3718

    题意:戳这里 思路:很容易发现对于一个车能否移动到最终的位置只要判断路径中得最大高度与自身高端之和是否>w即可. 那么就可以转化为逆序对得最大数问题..即对于每一辆车,判断有那些最初在他前面,而 ...

  3. 解决eclipse-helios中Errors running builder JavaScript Validator的问题(转)

    原文地址:http://hi.baidu.com/%B3%BF%D1%F4%C2%FE%B2%BD/blog/item/2528f6de3ca90955ccbf1a3f.html 最近下载了eclip ...

  4. 为什么没调用 didRegisterForRemoteNotificationsWithDeviceToken 和 didFailToRegisterForRemoteNotificationsWithError

    一步一步按照网上 push notification 教程走下来,发现didRegisterForRemoteNotificationsWithDeviceToken 和 didFailToRegis ...

  5. pivotx的entry和page内容里的日期格式修改

    欢迎转载opendevkit文章, 文章原始地址: http://www.opendevkit.com/?e=63 1. 文章发布时间的确定 如果服务器空间在国内还好说, 如果在国外的话, 文章编辑时 ...

  6. dojo分析之declare接口

    欢迎转载opendevkit文章, 文章原始地址: http://www.opendevkit.com/?e=57 declare接口是dojo定义类系统的关键函数, 类系统就是抽象,封装,继承.do ...

  7. [转载]并发编程之Operation Queue和GCD

    并发编程之Operation Queue http://www.cocoachina.com/applenews/devnews/2013/1210/7506.html 随着移动设备的更新换代,移动设 ...

  8. dubbo分布式rpc框架用法

    dubbo是阿里巴巴开源的分布式服务框架,致力于提供高性能和透明化的rpc远程服务调用方案,以及soa服务治理方案,如果没有分布式需求,是不需要dubbo的,分布式环境dubbo的使用架构官方给出了一 ...

  9. node(规则引擎)

    本文主要记录node的下的一个开源规则引擎nools,给出简单的实例,github地址为: https://github.com/C2FO/nools 定义规则引擎(test.nools) defin ...

  10. Java多线程8:wait()和notify()/notifyAll()

    轮询 线程本身是操作系统中独立的个体,但是线程与线程之间不是独立的个体,因为它们彼此之间要相互通信和协作. 想像一个场景,A线程做int型变量i的累加操作,B线程等待i到了10000就打印出i,怎么处 ...