{"id":18484152,"url":"https://github.com/jdf2e/jdf-extract-template","last_synced_at":"2025-05-13T21:12:59.986Z","repository":{"id":57279987,"uuid":"99118531","full_name":"jdf2e/jdf-extract-template","owner":"jdf2e","description":"【jdf插件】抽取widget模板中的前端模板，以字符串形式置入js文件中","archived":false,"fork":false,"pushed_at":"2017-08-07T03:39:14.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T21:37:31.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdf2e.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-02T13:19:21.000Z","updated_at":"2022-05-02T09:15:15.000Z","dependencies_parsed_at":"2022-09-18T13:23:26.373Z","dependency_job_id":null,"html_url":"https://github.com/jdf2e/jdf-extract-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-extract-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-extract-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-extract-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdf2e%2Fjdf-extract-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdf2e","download_url":"https://codeload.github.com/jdf2e/jdf-extract-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029008,"owners_count":22002284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T12:38:44.941Z","updated_at":"2025-05-13T21:12:54.969Z","avatar_url":"https://github.com/jdf2e.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jdf抽取插件\n将html中的前端模板抽取到js中\n\n## 注意点\n默认抽取带有`ext-id`属性的script标签，可以在`config.json`中设置`prefix`属性来改变它。\n\n`prefix`指的是模板script标签的一个属性\n```\n{\n    \"name\": \"jdf-extract-template\",\n    \"prefix\": \"channel-id\"\n}\n```\n\n在js中，目前只支持jQuery调用，形如：`var tpl = $(selector).html()`\n\n`selector`不能是变量!~~\n\n```js\n$('#id').html()\n$('.class').html()\n$('[]').html()\n$(selector).html()\n```\n## 示例\n```html\n\u003cdiv id=\"renderPlace\"\u003e\n    \u003cscript type=\"text/template\" ext-id=\"12\" id=\"floorTpl\"\u003e\n        \u003cspan\u003e我是模板:${floor_id}\u003c/span\u003e\n    \u003c/script\u003e\n\u003c/div\u003e\n```\n```js\ndefine(function () {\n    require('module1');\n    var tpl = $(\"#floorTpl\").html();\n    var data = {\n        floor_id: 1\n    }\n    $('#renderPlace').html(render(tpl, data))\n})\n```\n经过插件编译后\n```html\n\u003cdiv id=\"renderPlace\"\u003e\n\u003c/div\u003e\n```\n```js\ndefine(function () {\n    require('module1');\n    var tpl = '\u003cspan\u003e我是模板:${floor_id}\u003c/span\u003e';\n    var data = {\n        floor_id: 1\n    }\n    $('#renderPlace').html(render(tpl, data))\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-extract-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdf2e%2Fjdf-extract-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdf2e%2Fjdf-extract-template/lists"}