• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

art-template loader for webpack

art-template-loader

NPM Version Node.js Version

art-template loader for webpack

Install

npm install art-template
npm install art-template-loader --save-dev

Usage

By default every local <img src="image.png"> is required (require('./image.png')). You may need to specify loaders for images in your configuration (recommended file-loader or url-loader).

You can specify which attribute combination should be processed by this loader via the query parameter htmlResourceRules. (Default: htmlResourceRules=[/\bsrc="([^"]*)"/])

To completely disable tag-attribute processing (for instance, if you're handling image loading on the client side) you can pass in htmlResourceRules=false.

Examples

module.exports = {
    // ...
    module: {
        rules: [{
            test: /\.jpg$/,
            loader: "file-loader"
        }, {
            test: /\.png$/,
            loader: "url-loader?mimetype=image/png"
        }, {
            test: /\.art$/,
            loader: "art-template-loader",
            options: {
                // art-template options (if necessary)
                // @see https://github.com/aui/art-template
            }
        }]
    },
    // ...
}
<% include('./header.art') %>

<% if (user) { %>
  <h2><%= user.name %></h2>
  <p><img src="./octocat.png" alt="octocat"></p>
<% } %>

<% include('./footer.art') %>

More

'Root-relative' URLs

For urls that start with a /, the default behavior is to not translate them. If a htmlResourceRoot query parameter is set, however, it will be prepended to the url and then translated.

With the same configuration as above:

<!-- file.art -->
<img src="/image.jpg">
require("html-loader!./file.art");

// => '<img  src="/image.jpg">'
require("html-loader?htmlResourceRoot=.!./file.art");

// => '<img  src="http://cdn.example.com/49eba9f/a992ca.jpg">'

Filter

Add filter:

var runtime = require('art-template/lib/runtime');
runtime.dateFormat = function(){ /*[...]*/ };
var html = require('./index.art');

Use filter:

{{time | dateFormat 'yyyy-MM-dd hh:mm:ss'}}

Debug

Support SourceMap:

webpack --debug

debug

Options

You can pass art-template options using standard webpack loader options.

More Repositories

1

art-template

High performance JavaScript templating engine
JavaScript
9,851
star
2

font-spider

Smart webfont compression and format conversion tool
JavaScript
5,005
star
3

artDialog

经典的网页对话框组件
JavaScript
3,133
star
4

tmodjs

前端模板外置解决方案
JavaScript
665
star
5

pinyin-engine

JavaScript 拼音匹配引擎
HTML
471
star
6

gulp-font-spider

字蛛 gulp 插件
JavaScript
189
star
7

angular-popups

基于Angularjs的浮层组件
HTML
117
star
8

popupjs

W3C HTML5 Dialog Plus
JavaScript
112
star
9

node2bat

基于JScript的迷你NodeJS运行时
Shell
57
star
10

angular-drag

基于Angularjs的拖拽指令
HTML
55
star
11

browser-x

一个基于 NodeJS 实现的虚拟浏览器
JavaScript
49
star
12

jsonp-sandbox

jsonp sandbox
JavaScript
49
star
13

express-art-template

art-template for express
JavaScript
44
star
14

koa-art-template

a koa view render middleware, support all feature of art-template
JavaScript
41
star
15

grunt-font-spider

字蛛 grunt 插件
JavaScript
35
star
16

include-file

HTML 静态文件局部模板批量更新工具
HTML
23
star
17

blog

18
star
18

art-template-docs

art-template document
JavaScript
12
star
19

grunt-unwrap

将 CMD 模块转换成不依赖加载器的工具
JavaScript
9
star
20

vs-code-github-markdown-theme

vs code: markdown theme
CSS
7
star
21

koa-gitlab

simple gitlab auth middleware for koa
JavaScript
4
star
22

devtools-watcher

DevTools Watcher
HTML
3
star
23

sublime-art

art-template syntax definition for Sublime Text 3
3
star
24

file-cache-webpack-plugin

Webpack plugin that persists the compiler cache to the file system
JavaScript
2
star
25

free-fonts

收录字蛛可以压缩并且免费的字体
2
star
26

amd-to-commonjs

JavaScript
1
star
27

ISPAdBlock

ISP 广告拦截器
1
star
28

hexo-renderer-art

art-template renderer for Hexo
JavaScript
1
star