Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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 clarity

var 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

```