-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-mustache.js
48 lines (45 loc) · 1.35 KB
/
render-mustache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* render-mustache
*
* This module implements support for rendering [Mustache](http://mustache.github.com/)
* templates using [mustache.js](https://github.com/janl/mustache.js).
*/
define(['mustache'],
function(Mustache) {
/**
* Setup Mustache template engine.
*
* When rendering, this engine returns a compiled template function which can
* be cached for performance optimization.
*
* Examples:
*
* render.engine('text/x-mustache-template', mustache());
*
* A Note on MIME Types:
*
* It has become common convention to include templates within HTML by
* enclosing them within script tags:
*
* <script type=“text/template”>...</script>
*
* Recommended practice for Sail.js applications is to be more specific when
* indicating the MIME type, both as a way to communicate explicitly with
* other developers and as a means to use multiple template engines within an
* application.
*
* While no standard exists, the following list of MIME types are used to
* indicate Mustache templates in practice:
*
* * text/x-mustache-template
* [Announcing Handlebars.js](http://yehudakatz.com/2010/09/09/announcing-handlebars-js/)
*
* @return {Function}
* @api public
*/
return function() {
return function(str) {
return Mustache.compile(str);
}
}
});