bone-act-htmllayout

0.3.3 • Public • Published

bone-act-htmllayout

bone的layout处理器,为html文件提供layout功能

NPM version NPM version travis

安装及使用

通过npm安装

$ npm install bone-act-htmllayout 

安装后在bonefile.js文件内通过act()加载

var bone = require('bone');
var htmllayout = bone.require('bone-act-htmllayout');
 
bone.dest('dist')
    .src('~/src/index.html')
    .act(htmllayout);

index.html文件内容

<layout src="./layout.html" data-script="http://www.qq.com/ping.js" data-link="http://www.qq.com/style.css">
    <div>
        inner html code.
    </div>
</layout>

layout.html文件内容

<!doctype html>
<html lang="cn">
<head>
    <title></title>
    <% if(data.link) { 
        var links = data.link.split(',');
        for(var i in links) { 
    %>
    <link rel="stylesheet" type="text/css" href="<%= links[i] %>">
    <%  }} %>
    <% if(data.script) { 
        var scripts = data.script.split(',');
        for(var i in scripts) {
    %>
    <script type="text/javascript" src="<%= scripts[i] %>"></script> 
    <% }} %>
</head>
<body>
    <%= html %>
</body>
</html>

处理后

<html lang="cn">
<head>
    <title></title>
 
    <link rel="stylesheet" type="text/css" href="http://www.qq.com/style.css">
   
    <script type="text/javascript" src="http://www.qq.com/ping.js"></script> 
</head>
<body>
    <div>
        inner html code.
    </div>
</body>
</html>

filter

默认设置只针对源文件后缀为.html.htm文件进行处理

其他

处理器开发以及使用请参考处理器

Package Sidebar

Install

npm i bone-act-htmllayout

Weekly Downloads

8

Version

0.3.3

License

MIT

Last publish

Collaborators

  • wyicwx