Inspired from https://github.com/addyosmani/oust
Attribute | Required | Description |
---|---|---|
htmlString |
True | a valid HTML string to parse for references |
type |
True | one of stylesheets , scripts , styles , links , images |
cb |
False | Filter via callback |
First include:
const oust = require('oust');
console.log(oust('<link rel="stylesheet" href="styles/main.css">', 'stylesheets')); // output: ["styles/main.css"]
console.log(oust('<link rel="import" href="../polymer/polymer.html">', 'stylesheets', ($el, i) => {
return $el.attr('media') === 'print';
})); // output: ["../polymer/polymer.html"]
console.log(oust('<script src="scripts/main.js"></script>', 'scripts')); // output: ["scripts/main.js"]
console.log(oust('<style>body {padding:0}</style><style>h1 {font-size: 5rem}</style>', 'styles')); // output: ["body {padding:0}", "h1 {font-size: 5rem}"]
console.log(oust('<a href="contact.html">Contact</a>', 'links')); // output: ["contact.html"]
console.log(oust('<img src="http://placekitten.com/200/300">', 'images')); // output: ["http://placekitten.com/200/300"]