JSPM

handlebars-helper-sri

0.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q39562F

Sub-resource integrity in Handlebars

Package Exports

  • handlebars-helper-sri

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (handlebars-helper-sri) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

handlebars-helper-sri Build Status

Install

npm install --save handlebars-helper-sri

Usage

Attach the helper to handlebars:

var handlebars = require("handlebars");

handlebars = require("handlebars-helper-sri").register(handlebars);

Then, call the helper from your Handlebars template:

<script src="/script.js" integrity="{{sri "./public/script.js"}}"></script>
<link href="/style.css" integrity="{{sri "./public/style.css"}}" rel="stylesheet">

Caching

You may wish to attach a custom subresource instance, for pre-load caching:

var handlebars = require("handlebars");
var subresource = require("subresource");

[
    "../public/script.js",
    "../public/style.css"
].forEach(subresource);

handlebars = require("handlebars-helper-sri").register(handlebars, subresource);