Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/panthershark/vdom-versionify
Sets version as a data attr when rendering a virtual dom node or tree.
https://github.com/panthershark/vdom-versionify
Last synced: about 2 months ago
JSON representation
Sets version as a data attr when rendering a virtual dom node or tree.
- Host: GitHub
- URL: https://github.com/panthershark/vdom-versionify
- Owner: panthershark
- License: mit
- Created: 2015-05-28T21:16:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-29T15:52:05.000Z (over 9 years ago)
- Last Synced: 2024-04-15T14:27:07.169Z (9 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vdom-versionify
Gulp task which generates a versioned attr on DOM elements so you can track what module generated the piece of the DOM you are inspecting.# Usage
The gulp task is used to generate a package specific versionify helper for decorating the DOM with information that assists in inspecting a real DOM and tracing back to the package which generated the vdom.
### Gulp
```
// var packageJSON = require('./package.json'); //==> you would use this, but this example has it commented out for clarityvar packageJSON = {
"name": "dogs",
"version": "1.2.3"
};
var vdom_versionify = require('vdom-versionify');gulp.task('versionify', function () {
return vdom_versionify(packageJSON, 'data-foo')
.pipe(source("versionify.js"))
.pipe(gulp.dest('./'));
});
```### In code
Once you generate the versionify function in gulp, you can use it to wrap your render functions.
```
var versionify = require('./versionify.js');
var dog = function (d) {
return h('li', d);
};var render = versionify(function (dog_names) {
return h('ul', dog_names.map(dog));
});console.log(toHTML(render(['Lucky', 'Biggie Smalls', 'Tupac'])));
```
The above emits the following HTML
```
- Lucky
- Biggie Smalls
- Tupac
```