New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jdf-extract-template

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jdf-extract-template

extract template to js

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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不能是变量!~~

$('#id').html()
$('.class').html()
$('[]').html()
$(selector).html()

示例

<div id="renderPlace">
    <script type="text/template" ext-id="12" id="floorTpl">
        <span>我是模板:${floor_id}</span>
    </script>
</div>
define(function () {
    require('module1');
    var tpl = $("#floorTpl").html();
    var data = {
        floor_id: 1
    }
    $('#renderPlace').html(render(tpl, data))
})

经过插件编译后

<div id="renderPlace">
</div>
define(function () {
    require('module1');
    var tpl = '<span>我是模板:${floor_id}</span>';
    var data = {
        floor_id: 1
    }
    $('#renderPlace').html(render(tpl, data))
})

FAQs

Package last updated on 07 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts