Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-cache-loader

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-cache-loader

Webpack loader to put HTML partials in the Angular's $templateCache.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-10.58%
Maintainers
1
Weekly downloads
 
Created
Source

Angular Template loader for webpack

Puts HTML partials in the Angular's $templateCache so directives can use templates without initial downloading.

Webpack and loaders

Webpack is webpack and it's module bundler. Loaders wrap content in the javascript code that executes in the browser.

Install

npm install ng-cache-loader

Usage

You can require html partials via ng-cache-loader:

require('ng-cache!./demo/template/myPartial.html');

Partial will be available as ng-include="'myPartial.html'" or templateUrl: 'myPartial.html'.

Named templates

You can wrap template in the script tag:

<!-- ./demo/template/myPartial.html -->

<script type ="text/ng-template" id="myFirstTemplate">
  <!-- then use ng-include="'myFirstTemplate'" -->
</script>

You can have multiple templates in one file:

<!-- ./demo/template/myPartial.html -->

<script type ="text/ng-template" id="myFirstTemplate">
  <!-- then use ng-include="'myFirstTemplate'" -->
</script>

<script type ="text/ng-template" id="mySecondTemplate">
  <!-- then use ng-include="'mySecondTemplate'" -->
</script>

You can mix named templates and simple markup:

<!-- ./demo/template/myPartial.html -->

<script type ="text/ng-template" id="myFirstTemplate">
  <!-- then use ng-include="'myFirstTemplate'" -->
</script>

<!-- markup outside script tags available as ng-include="'myPartial.html'" -->
<div>...</div>

<script type ="text/ng-template" id="mySecondTemplate">
  <!-- then use ng-include="'mySecondTemplate'" -->
</script>

Prefix

Prefix adds path left of template name:

require('ng-cache?prefix=public/templates!./path/to/myPartial.html')
// => ng-include="'public/templates/myPartial.html'"

Prefix can mask the real directory with the explicit value or can retrieve the real directory (use [dir]):

require('ng-cache?prefix=public/[dir]/templates!./path/to/myPartial.html')
// => ng-include="'public/path/templates/myPartial.html'" 

Prefix can strip the real directory (use //):

require('ng-cache?prefix=public//[dir]/templates!./far/far/away/path/to/myPartial.html')
// => ng-include="'public/far/path/templates/myPartial.html'" 

webpack config

Match .html extension with loader:

module: {
    loaders: [
        {
            test: /.html$/,
            loader: "ng-cache?prefix=[dir]/[dir]"
        }
    ]
},

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

FAQs

Package last updated on 27 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc