attribute-store
Store template context on data attributes in static HTML, allowing metadata to be retrieved/updated post-render.
Install
npm:
Install withnpm i attribute-store --save-dev
Usage
var attrStore = ;
This is foo.html
:
---title: Home--- Document this is the body
.set()
To store the YAML front matter from foo.html
in data attributes:
// Read the file in as a stringvar str = fs; // pass the string to attribute-storevar store = ;
To store the data from the front-matter in data attributes (by default data is stored on data-metadata
on a script tag with the metadata
id):
store;console;
Results in:
Document this is the body
.get()
Get the data:
store;
id
Set a custom id:
store;// to get the data:store;
extend
YAML front matter is stored by default. If an object is passed any existing front-matter will be extended.
If front-matter doesn't exist, just pass an object to store:
store;
Results in:
Document this is the body
Or with a custom id:
store;
Results in:
Document this is the body
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on November 17, 2014.