https://github.com/y8n/inline-template-loader
a webpack loader to inline template as string
https://github.com/y8n/inline-template-loader
inline-templates loader template webpack
Last synced: 4 months ago
JSON representation
a webpack loader to inline template as string
- Host: GitHub
- URL: https://github.com/y8n/inline-template-loader
- Owner: y8n
- Created: 2017-05-15T05:00:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-15T05:01:55.000Z (about 9 years ago)
- Last Synced: 2025-05-09T05:51:37.148Z (about 1 year ago)
- Topics: inline-templates, loader, template, webpack
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# inline-template-loader
## Install
```
npm install inline-template-loader
```
## Usage
```javascript
// webpack.conf.js
module: {
rules:[{
test: /\.js$/,
loader: 'inline-template-loader'
}]
}
```
## Output
```javascript
// index.js
function foo(){
return __inline('./template.html');
}
```
```html
// template.html
HelloWorld
```
```javascript
// output.js
function foo(){
return '
HelloWorld
';
}
```
## options
```javascript
// webpack.conf.js
module: {
rules:[{
test: /\.js$/,
loader: 'inline-template-loader',
options: {
pattern: /__template(/ // 正则
replcement: function(m){ // 替换方法
return m.slice(1);
}
}
}]
}
```
## License
MIT