gulp-micro-templates

gulp plugin for `micro-template` by John Resig

Usage no npm install needed!

<script type="module">
  import gulpMicroTemplates from 'https://cdn.skypack.dev/gulp-micro-templates';
</script>

README

gulp-micro-template

Build Status

Respecting micro-templating

why

spec

Make soruce files (.html)

<!-- ./tpl/foo.html -->
<a href="<%= url %>"><%= name %></a>
<!-- ./tpl/bar/baz.html -->
<% for ( var i = 0; i < users.length; i++ ) { %>
  <li><a href="<%=users[i].url%>"><%=users[i].name%></a></li>
<% } %>

to

this.MicroTemplates = {
    "tpl/foo.html": "<a href=\"<%= url %>\"><%= name %></a>",
    "tpl/bar/baz.html": "<% for ( var i = 0; i < users.length; i++ ) { %>
  <li><a href=\"<%=users[i].url%>\"><%=users[i].name%></a></li>
<% } %>"
};

usage

gulpfile.js

var microtemplate = require('gulp-micro-template');
gulp.task('microt',function(){
    gulp.src('./tpl/**/*.html')
    .pipe(microtemplate('all.js'))
    .pipe(gulp.dest('./build/tpl'));
});