https://github.com/litten/gulp-amd-template
to compile HTML templates into JS source code with AMD.
https://github.com/litten/gulp-amd-template
Last synced: 2 months ago
JSON representation
to compile HTML templates into JS source code with AMD.
- Host: GitHub
- URL: https://github.com/litten/gulp-amd-template
- Owner: litten
- License: mit
- Created: 2015-05-20T08:38:20.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-20T08:57:21.000Z (about 11 years ago)
- Last Synced: 2025-05-09T05:19:10.848Z (over 1 year ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-amd-template
To compile templates into JS source code with AMD.
## Install
Install with [npm](https://www.npmjs.org/package/gulp-amd-template)
```
npm install --save-dev gulp-amd-template
```
##Usage
```js
gulp.task('tpl', function(){
gulp.src('source/tpl/'+'**/*.tpl')
.pipe(template())
.pipe(gulp.dest('dist'));
})
```
## Example
### source `demo.html`
```html
<%for(var i=0,len=list.length; i
<%for(var em in list[i]){%>
<%if(list[i][em] == "time"){%>
<%var time = list[i][em]%>
<%=time%>
<%}%>
<%}%>
<%}%>
```
Compile into
### `demo.js`
```js
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else {
root['demo'] = factory();
}
} (this,
function() {
return function(it, opt) {
it = it || {};
with(it) {
var _$out_ = [];
for (var i = 0,
len = list.length; i < len; i++) {
_$out_.push('
for (var em in list[i]) {
if (list[i][em] == "time") {
var time = list[i][em] _$out_.push('
', time, '
');}
}
}
return _$out_.join('');
}
}
```
## Changelog
#### 1.0:
* **BREAKING**: Init Proj
## License
MIT © Emanuele Ingrosso