CustomAttribute
Details | |
---|---|
name | CustomAttribute |
type | class |
properties | execute, bind |
methods | process, render |
description | A class to extend in order to create custom HTML+ attributes |
Constructor
The constructor takes no argument.
Properties
- execute
- type: boolean, optional : flags whether to execute the string value to a Javascript value.
- render
- type: boolean, optional : flags whether to bind the string value to another string value.
Methods
- process
- arguments: raw attribute value : a function called before value bind and execution that must return a new string representing the new attribute value to be bind or executed.
- render
- arguments: processed attribute value, Element instance : a function called on node render that must return the node or a new HTML markup string.
Usage Examples
This is how the native #if attribute is implemented.
const {CustomAttribute} = require("@beforesemicolon/html-plus");
class If extends CustomAttribute {
execute = true;
render(condition, node) {
return condition ? node : null;
}
}
module.exports.If = If;