Class: Node Abstract
Defined in: | 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:
Each node must mark the @opener
attribute and can optionally mark the @closer
attribute.
Direct Known Subclasses
Code, Comment, Filter, Haml, Text
Constant Summary
-
CLEAR_WHITESPACE_LEFT
=
Hidden unicode marker to remove left whitespace after template rendering.
-
'\u0091'
-
CLEAR_WHITESPACE_RIGHT
=
Hidden unicode marker to remove right whitespace after template rendering.
-
'\u0092'
Instance Method Summary
- - (void) constructor(expression = '', options = {}) Constructor Constructs a syntax node.
- - (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.
- - (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() Abstract 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.
- (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.