Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Assesses & extracts references to all the assets in your markup.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
package.json
readme.md

readme.md

assetment Build Status

Assesses & extracts references to all the assets in your markup.

Getting Started

npm install --save assetment

Usage

Pass assetment() a String of markup and an Object with the types of assets you would like to extract.

var assetment = require( "assetment" );
var markup = fs.readFile( "filename.html", "utf8" );
var filters = {
  images: true,
  javascripts: true,
  stylesheets: true
}


console.log( assetment( markup, filters ) );
/*
{
  images: [
    {
      resource: "image.png",
      attributes: { alt: "image", src: "image.png" }
    {
  ],
  javascripts: [
    {
      resource: "script.js",
      attributes: { type: "text/javascript", src: "script.js" }
    {
  ],
  stylesheets: [
    {
      resource: "style.css",
      attributes: { type: "text/css" , src: "style.css" }
    {
  ]
}
*/

API

assetment( markup, filters )

Name Type Argument Default Description
markup string <required> null Markup that you would like to extract the assets from.
filters Object <required> null Object that contains the types of assets you want to extract.
filters.images boolean <optional> false Extract references to image files.
filters.javascripts boolean <optional> false Extract references to JavaScript files.
filters.stylesheets boolean <optional> false Extract references to stylesheet files.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2014 Jason Bellamy
Licensed under the MIT license.

Something went wrong with that request. Please try again.