npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-ng-template-html

v0.1.1

Published

Precompile AngularJS templates to a JS file and html file

Downloads

13

Readme

gulp-ng-template-html

Precompile AngularJS templates to a JS file(angular load function compile it, so that can add it into $templateCache.) and html file(all is dom element)

this repo is branch of gulp-ng-template(some codes are come from gulp-ng-template), if you want to use gulp ng-template, please move to gulp-ng-template.

Thanks Teambition for contribute gulp-ng-template!

Difference

###gulp-ng-template-html compile your html file into 2 file, one is js,one is html. js will provide a loadedTemplateUrl function for load your template, after load done will automate compile it into $templateCache.

###gulp-ng-template Precompile AngularJS templates to a JS file with $templateCache. It put all the html into js.

Install

Install with npm

npm install --save-dev gulp-ng-template-html

Usage

var minifyHtml = require('gulp-minify-html');
var ngTemplate = require('gulp-ng-template-html');

gulp.task('templates:dist', function() {
  gulp.src('src/tpl/**/*.html')
    .pipe(minifyHtml({empty: true, quotes: true}))
    .pipe(ngTemplate({
      moduleName: 'myTemplates',
      standalone: true
    }))
    .pipe(uglify())  //you want mini all js? use this
    .pipe(gulp.dest('dist'));  // output file: 'dist/js/templates.js'&'dist/js/templates.html'
});

Demo

test/a.html:

<div class="test">A</div>

test/b.html:

<div class="test">
  <span>B</span>
</div>

gulp test:

gulp.task('test', function () {
  return gulp.src(['test/a.html', 'test/b.html'])
    .pipe(ngTemplate())
    .pipe(gulp.dest('test'));
});

test/js/templates.js:

;(function(angular){
  'use strict';

  var appConfig = angular.module('testModule', []);

  appConfig.config(['$provide', function ($provide) {
    $provide.decorator('$templateCache', ['$http', '$delegate', '$injector', function ($http, $delegate, $injector) {
      $delegate.loadedTemplateUrl = function (url) {
        $http({
          url: url,
          method: 'GET'
        }).then(function (response) {
          if (response.status === 200) {
            $injector.get('$compile')(response.data);
          }
        });
      };
      return $delegate;
    }]);
  }]);

  appConfig.run(['$templateCache', '$http', '$compile', function ($templateCache, $http, $compile) {
    //TODO:please replace you URL or Use this loadedTemplateUrl to load a template
    $templateCache.loadedTemplateUrl('your URL address');
    //demo: $templateCache.loadedTemplateUrl('/template/ng-template.html');
  }]);

})(angular);

test/js/templates.html:


<script type="text/ng-template" id="a.html">
  <div class="test">A</div>

</script>

<script type="text/ng-template" id="b.html">
  <div class="test">
  <span>B</span>
</div>

</script>

Options

moduleName

Optional, Type: String, Default: 'ngTemplates'.

Name of the AngularJS module.

standalone

Optional, Type: Boolean, Default: false.

Create an AngularJS module.

License

MIT