1.0.1 • Published 9 years ago

gulp-template-generator v1.0.1

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

Build Status

Information

Usage

var generateTemplate = require('gulp-template-generator');

gulp.task('generate-template', function() {

  return gulp.src('./static/html/*.html')
    .pipe(generateTemplate('static')) //either 'static' or 'template'
    .pipe(gulp.dest('./dist/'));
});

HTML COMMENTS

In your HTML you can tell the gulp plugin what to add and remove when it runs. Anything in a

<!--DEL--><!--/DEL-->

comment will be removed.

Anything in a

<!--ADD--><!--/ADD-->

comment will be added.

EXAMPLE

The following example contains both static HTML (great for developing) and template tags:

<h2><!--DEL-->This is the title<!-- /DEL --><!-- ADD--><% title %><!--/ADD--></h2>

<!--ADD-->
  <strong>some emphasised text</strong>
<!--/ADD-->
<ul>
  <!--ADD--><% for each item in list %>   <!--/ADD--> <li><!--DEL-->This is the first item in the list<!--/DEL--><!--ADD--><% item %><!--/ADD--></li><!--ADD--><% end for %><!--   /ADD -->
  <!--DEL--><li>This is the second item in the list</li><!--/DEL -->
  <!--DEL--><li>This is the <strong>third</strong> item in the list</li><!-- /DEL    -->
</ul>

When using generateTemplate('static'), this will render as:

<h2>This is the title</h2>

<ul>
  <li>This is the first item in the list</li>
  <li>This is the second item in the list</li>
  <li>This is the <strong>third</strong> item in the list</li>
</ul>

When using generateTemplate('template'), this will render as:

<h2><% title %></h2>

  <strong>some emphasised text</strong>
<ul>
  <% for each item in list %><li><% item %></li><% end for %>
</ul>

LICENSE

(MIT License)

Copyright (c) 2015 Richard Willars (richard@richardwillars.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.