mm_tpl 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README_EN.md +2 -2
- package/lib/tpl.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -977,7 +977,7 @@ tpl.clearCache('./zh_cn');
|
|
|
977
977
|
|
|
978
978
|
#### 模板函数表
|
|
979
979
|
|
|
980
|
-
用 `setFunc` 注册模板函数,注册后每次渲染都注入模型,模板内直接按名调用;`
|
|
980
|
+
用 `setFunc` 注册模板函数,注册后每次渲染都注入模型,模板内直接按名调用;`delFunc` 删除,`getFuncs` 取全部:
|
|
981
981
|
|
|
982
982
|
```javascript
|
|
983
983
|
tpl.setFunc('$md', function (text) {
|
|
@@ -1024,7 +1024,7 @@ tpl.hook.addAction('header', function (m) { return '<header>实例级</header>';
|
|
|
1024
1024
|
- `runHook(name, req, ...args)` - 执行函数钩子(runFunc 别名)
|
|
1025
1025
|
- `escape(body, restore)` - 转义/还原字符
|
|
1026
1026
|
- `setFunc(name, func)` - 注册模板函数,每次渲染都注入模型供模板内调用;内置函数与本次 `model` 的同名字段优先
|
|
1027
|
-
- `
|
|
1027
|
+
- `delFunc(name)` - 删除已注册的模板函数,返回是否存在并删除成功
|
|
1028
1028
|
- `getFuncs()` - 获取模板函数表
|
|
1029
1029
|
|
|
1030
1030
|
### Tpl 多用户相关方法
|
package/README_EN.md
CHANGED
|
@@ -987,7 +987,7 @@ tpl.clearCache('./zh_cn');
|
|
|
987
987
|
|
|
988
988
|
#### Template Function Table
|
|
989
989
|
|
|
990
|
-
Register template functions with `setFunc`; they are injected into the model on every render and can be called by name inside templates. `
|
|
990
|
+
Register template functions with `setFunc`; they are injected into the model on every render and can be called by name inside templates. `delFunc` deletes one and `getFuncs` returns them all:
|
|
991
991
|
|
|
992
992
|
```javascript
|
|
993
993
|
tpl.setFunc('$md', function (text) {
|
|
@@ -1034,7 +1034,7 @@ tpl.hook.addAction('header', function (m) { return '<header>instance-level</head
|
|
|
1034
1034
|
- `runHook(name, req, ...args)` - Execute function hooks (alias of runFunc)
|
|
1035
1035
|
- `escape(body, restore)` - Escape/restore characters
|
|
1036
1036
|
- `setFunc(name, func)` - Register a template function injected into the model on every render for templates to call; built-in functions and fields of the same name in this call's `model` take precedence
|
|
1037
|
-
- `
|
|
1037
|
+
- `delFunc(name)` - Delete a registered template function, returns whether it existed and was removed
|
|
1038
1038
|
- `getFuncs()` - Get the template function table
|
|
1039
1039
|
|
|
1040
1040
|
### Tpl Multi-user Methods
|
package/lib/tpl.js
CHANGED
|
@@ -944,7 +944,7 @@ Tpl.prototype.setFunc = function (name, func) {
|
|
|
944
944
|
* @param {string} name - 函数名
|
|
945
945
|
* @returns {boolean} 是否存在并删除成功
|
|
946
946
|
*/
|
|
947
|
-
Tpl.prototype.
|
|
947
|
+
Tpl.prototype.delFunc = function (name) {
|
|
948
948
|
if (this.funcs[name] === undefined) {
|
|
949
949
|
return false;
|
|
950
950
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_tpl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Super Meimei Template Engine - High-performance template engine based on art-template with MVC pattern, hook system, theme switching and caching mechanism",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"io": true,
|