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

angular-template-cache-brunch

v2.0.5

Published

Insert angular templates into $templateCache. Configurable with cool ES6 syntax

Downloads

15

Readme

js-standard-style Coverage Status Build Status Dependency Status

Angular TemplateCache plugin for brunch

Mimics gulp-angular-templatecache behavior for brunch. For the most part at least. This compiles all partial templates into one file, using one module, which should be the one main module of your angular app. Things are much simpler this way when it comes to the cool stuff.

The reason for the single module it to allow easy integration with npm enabled es6 module oriented brunch configuration. This is actually the whole reason why i reinvented the wheel with this brunch plugin.

Installation

npm i -S angular-template-cache-brunch

NOTE: In order for this plugin to recognize templates, they must have a .tpl.html extension.

Usage

- templates joinTo

Set joinTo attribute for templates in brunch-config.coffee, e.g.

templates:
  joinTo:
    'js/templates.js': /^app/

- markup

In your markup, include js/templates.js:

<script type="text/javascript" src="js/templates.js"></script>

- angular usage

Use a templateUrl in something like ui.router's awesome state based system

angular.module('app').config($stateProvider => {
  $stateProvider
    .state('home', {
      url: '/home',
      templateUrl: 'home.tpl.html'
    })
})

- profit

Run Brunch (e.g. brunch build)

Options

- module

Default module name is app. Configurable in the plugins section of brunch-config.coffee

plugins:
  angular_templates:
    module: 'myApp'

- transform path

Optional path transform function

plugins:
  angular_templates:
    pathTransform: (path) ->
     path.replace 'my/boring/initial/path', ''

- htmlmin

We use defaults of npm i -S minimize for htmlmin of the templates.

plugins:
  angular_templates:
    htmlmin:
      empty: true

Example Output

All templates end up as a bunch of angular module getters with a run component injecting $templateCache

(function() {
angular.module("app").run(["$templateCache", function($templateCache) {
  $templateCache.put("app/first.tpl.html",
    "<div id=first class=hotshit></div>")}])
})()

(function() {
angular.module("app").run(["$templateCache", $templateCache => {
  $templateCache.put("app/second/deeper.tpl.html",
    "<div id=second class=coolshit></div>")}])
})()

Dev

  1. src is a small es6 class with some experimental es7 shit. Uses new babel6 to build. Sorry if that pisses someone off. I really wanted to use the class properties for some reason.

  2. npm run build will build src dir into es5 and stick into lib

Holy shit tests

  1. Sadly, this is pretty much my first actual testing of pretty much anything client side i have ever wrote.

  2. Standard mocha setup, i don't like the nested describe/it blocks with global state so the ui is qunit

  3. npm test or to watch npm run bdd. Uses a nice spec reporter i stole from one of the geniuses in the node community. There are so many of them i can't remember which one.

  4. This now includes coveralls and at the mean time has 100% coverage