Text
Details | |
---|---|
name | Text |
type | class |
arguments | A text string |
properties | value, type |
methods | toString |
description | A class representing HTML comment. |
Constructor
The constructor takes the text string. It is the same as calling the createNodeText on the document in the browser.
Properties and Methods
The text instance is a server-side replica of the browser text node. It shares the node most properties and methods.
Context
You can set and read context on the text node which is a feature unique to HTML+ that allows you to define the data the text can refer to for rendering.
const {Text} = require("@beforesemicolon/html-plus");
const text = new Text('total is {total}');
text.setContext('total', 200);
comment.nodeValue; // 'total is {total}'
comment.nodeName; // '#text'
comment.nodeType; // '3'
// when rendered it will become
// 'total is 200'