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

fuse-box-ng-template-plugin

v1.0.4

Published

Includes your AngularJS templates into the fuse-box bundle

Downloads

22

Readme

fuse-box-ng-template-plugin npm version Build Status Windows Build status

AngularJS template plugin for FuseBox

Includes your AngularJS templates into your fuse-box bundle. Pre-loads the AngularJS template cache to remove initial load times of templates.

Inspired by ngtemplate-loader

Install

With npm

npm install --save-dev fuse-box-ng-template-plugin

With yarn

yarn add --dev fuse-box-ng-template-plugin

Usage

Just call NgTemplatePlugin within the FuseBox plugins array.

const { FuseBox } = require("fuse-box");
const NgTemplatePlugin = require("fuse-box-ng-template-plugin");

const fuse = FuseBox.init({
  homeDir: "./src",
  plugins: [NgTemplatePlugin()]
});

NgTemplatePlugin will export the path of the HTML file, so you can use require / import within your AngularJS code.

import templateUrl from "./test.html";

app.directive("testDirective", () => {
  return {
    restrict: "E",
    templateUrl
  };
});

Configuration

relativeTo and prefix

You can set the base path of your templates using relativeTo and prefix parameters. relativeTo is used to strip a matching prefix from the absolute path of the input html file. prefix is then appended to path.

The prefix of the path up to and including the first relativeTo match is stripped, e.g.

NgTemplatePlugin({
  relativeTo: "/src/"
});

'/test/src/test.html' will be stripped to 'test.html' within the $templateCache.

To match from the start of the absolute path prefix a '//', e.g.

NgTemplatePlugin({
  relativeTo: "//Users/fuse-box/project/test/"
});

It will be stripped to 'src/test.html' within the $templateCache.

You can combine relativeTo and prefix to replace the prefix in the absolute path, e.g.

NgTemplatePlugin({
  relativeTo: "src/",
  prefix: "build/"
});

'/test/src/test.html' will be transformed to 'build/test.html'.

module

By default NgTemplatePlugin adds a run method to the global 'ng' module, which does not need to be explicitly required by your app.

You can override this by setting the module parameter, e.g.

NgTemplatePlugin({
  module: "myTemplates"
});

// => returns the javascript:
angular.module("myTemplates").run([
  "$templateCache",
  function(c) {
    c.put("file.html", "<file.html processed by html-loader>");
  }
]);

Please make sure the specified module is initialized within your code.

HMR

By default the built-in FuseBox hmr does not work with AngularJS, but you can write a custom hmr plugin within your code.

For an example implementation, have a look at the AngularJS example.

Otherwise please force a reload within your fuse.js

app.hmr({
  reload: true
});

License

MIT