Comparing version 0.0.3 to 0.0.4
@@ -84,3 +84,6 @@ 'use strict'; | ||
value: function _getElementValue(element) { | ||
if (element.nodeName === 'INPUT') return element.value; | ||
if (element.nodeName === 'INPUT') { | ||
if (element.type === 'checkbox' || element.type === 'radio') return element.checked; | ||
return element.value; | ||
} | ||
return element.innerHTML; | ||
@@ -134,3 +137,6 @@ } | ||
if (!element) return; | ||
if (element.nodeName === 'INPUT') element.value = value;else element.innerHTML = value; | ||
if (element.nodeName === 'INPUT') { | ||
if (element.type === 'checkbox' || element.type === 'radio') element.checked = value; | ||
element.value = value; | ||
} else element.innerHTML = value; | ||
} | ||
@@ -137,0 +143,0 @@ }, { |
{ | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"name": "tplify", | ||
@@ -4,0 +4,0 @@ "description": "A simple html template compiler plugin for Browserify", |
# tplify | ||
A Browserify plugin used internally at Timpex AS that allows to `require` html templates. | ||
## Installation | ||
`npm install tplify` | ||
### Add to build | ||
```javascript | ||
browserify({...}) | ||
.plugin('tplify') | ||
.bundle(); | ||
``` | ||
## Usage | ||
### Javascript | ||
```javascript | ||
var view = require('./path/to/view.tpl.html'); | ||
view.activate(parentNode); | ||
view.deactivate(); | ||
view.setData({data-property: value, ...}); | ||
view.getData(); // => {data-property: value, ...} | ||
view.data-name; // => HTMLElement | ||
``` | ||
### Template | ||
```html | ||
// available for view.setData({someProperty: value}) and view.getData(); | ||
<div data-property="someProperty"></div> | ||
// available as property on view.someName | ||
<div data-name="someName"></div> | ||
``` |
@@ -59,4 +59,7 @@ export default class View { | ||
_getElementValue(element) { | ||
if (element.nodeName === 'INPUT') | ||
if (element.nodeName === 'INPUT') { | ||
if (element.type === 'checkbox' || element.type === 'radio') | ||
return element.checked; | ||
return element.value; | ||
} | ||
return element.innerHTML; | ||
@@ -104,4 +107,7 @@ } | ||
if (!element) return; | ||
if (element.nodeName === 'INPUT') | ||
if (element.nodeName === 'INPUT') { | ||
if (element.type === 'checkbox' || element.type === 'radio') | ||
element.checked = value; | ||
element.value = value; | ||
} | ||
else | ||
@@ -108,0 +114,0 @@ element.innerHTML = value; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26303
640
33