Class: Node Abstract
Defined in: | node_modules/grunt-codo/node_modules/codo/node_modules/haml-coffee/src/nodes/node.coffee |
Overview
Base class for the syntax tree.
This will provide some methods that subclasses must use in order to generate some output:
- {#markText}
- {#markRunningCode}
- {#markInsertingCode}
Each node must mark the @opener
attribute and can optionally mark the @closer
attribute.
Direct Known Subclasses
Code Comment Directive Filter Haml Text
Variables Summary
- CLEAR_WHITESPACE_LEFT =
-
'\u0091'
Hidden unicode marker to remove left whitespace after template rendering.
- CLEAR_WHITESPACE_RIGHT =
-
'\u0092'
Hidden unicode marker to remove right whitespace after template rendering.
Instance Method Summary
- # (void) addChild(child) Add a child node.
- # (String) getOpener() Get the opening tag for the node.
- # (String) getCloser() Get the closing tag for the node.
- # (Boolean) isPreserved() Traverse up the tree to see if a parent node is preserving output space.
- # (Boolean) isCommented() Traverse up the tree to see if a parent node is a comment node.
- # (Object) markText(text, escape = false) Creates a marker for static outputted text.
- # (Object) markRunningCode(code) Creates a marker for running CoffeeScript code that doesn't generate any output.
- # (Object) markInsertingCode(code, escape = false, preserve = false, findAndPreserve = false) Creates a marker for inserting CoffeeScript code that generate an output.
- # (void) evaluate() Template method that must be implemented by each Node subclass.
- # (Array) render() Render the node and its children.
Constructor Details
#
(void)
constructor(expression = '', options = {})
Constructs a syntax node.
Instance Method Details
#
(void)
addChild(child)
Add a child node.
#
(String)
getOpener()
Get the opening tag for the node.
This may add a hidden unicode control character for later whitespace processing:
\u0091
Cleanup surrounding whitespace to the left\u0092
Cleanup surrounding whitespace to the right
#
(String)
getCloser()
Get the closing tag for the node.
This may add a hidden unicode control character for later whitespace processing:
\u0091
Cleanup surrounding whitespace to the left\u0092
Cleanup surrounding whitespace to the right
#
(Boolean)
isPreserved()
Traverse up the tree to see if a parent node is preserving output space.
#
(Boolean)
isCommented()
Traverse up the tree to see if a parent node is a comment node.
#
(Object)
markText(text, escape = false)
Creates a marker for static outputted text.
#
(Object)
markRunningCode(code)
Creates a marker for running CoffeeScript code that doesn't generate any output.
#
(Object)
markInsertingCode(code, escape = false, preserve = false, findAndPreserve = false)
Creates a marker for inserting CoffeeScript code that generate an output.
#
(void)
evaluate()
Template method that must be implemented by each
Node subclass. This evaluates the @expression
and save marks the output type on the @opener
and
@closer
attributes if applicable.
#
(Array)
render()
Render the node and its children.
Always use @opener
and @closer
for content checks,
but @getOpener()
and @getCloser()
for outputting,
because they may contain whitespace removal control
characters.