https://github.com/jdf2e/jdf-extract-template
【jdf插件】抽取widget模板中的前端模板,以字符串形式置入js文件中
https://github.com/jdf2e/jdf-extract-template
Last synced: about 1 year ago
JSON representation
【jdf插件】抽取widget模板中的前端模板,以字符串形式置入js文件中
- Host: GitHub
- URL: https://github.com/jdf2e/jdf-extract-template
- Owner: jdf2e
- Created: 2017-08-02T13:19:21.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T03:39:14.000Z (almost 9 years ago)
- Last Synced: 2025-04-08T21:37:31.174Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
Awesome Lists containing this project
README
# jdf抽取插件
将html中的前端模板抽取到js中
## 注意点
默认抽取带有`ext-id`属性的script标签,可以在`config.json`中设置`prefix`属性来改变它。
`prefix`指的是模板script标签的一个属性
```
{
"name": "jdf-extract-template",
"prefix": "channel-id"
}
```
在js中,目前只支持jQuery调用,形如:`var tpl = $(selector).html()`
`selector`不能是变量!~~
```js
$('#id').html()
$('.class').html()
$('[]').html()
$(selector).html()
```
## 示例
```html
<span>我是模板:${floor_id}</span>
```
```js
define(function () {
require('module1');
var tpl = $("#floorTpl").html();
var data = {
floor_id: 1
}
$('#renderPlace').html(render(tpl, data))
})
```
经过插件编译后
```html
```
```js
define(function () {
require('module1');
var tpl = '我是模板:${floor_id}';
var data = {
floor_id: 1
}
$('#renderPlace').html(render(tpl, data))
})
```