Class: Node Abstract

Defined in: node_modules/grunt-codo/node_modules/codo/node_modules/haml-coffee/src/nodes/node.coffee

Overview

This class is abstract.

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 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

Constructor Details

# (void) constructor(expression = '', options = {})

Constructs a syntax node.

Parameters:

  • expression ( String ) the Haml expression to evaluate
  • options ( Object ) the node options

Options Hash: (options):

  • parentNode ( Node ) the parent node
  • blockLevel ( Number ) the HTML block level
  • codeBlockLevel ( Number ) the CoffeeScript block level
  • escapeHtml ( Boolean ) whether to escape the rendered HTML or not
  • format ( String ) the template format, either xhtml, html4 or html5

Instance Method Details

# (void) addChild(child)

Add a child node.

Parameters:

  • child ( Node ) the 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

Returns:

  • ( String ) — the opening tag

# (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

Returns:

  • ( String ) — the closing tag

# (Boolean) isPreserved()

Traverse up the tree to see if a parent node is preserving output space.

Returns:

  • ( Boolean ) — true when preserved

# (Boolean) isCommented()

Traverse up the tree to see if a parent node is a comment node.

Returns:

  • ( Boolean ) — true when within a comment

# (Object) markText(text, escape = false)

Creates a marker for static outputted text.

Parameters:

  • html ( String ) the html to output
  • escape ( Boolean ) whether to escape the generated output

Returns:

  • ( Object ) — the marker

# (Object) markRunningCode(code)

Creates a marker for running CoffeeScript code that doesn't generate any output.

Parameters:

  • code ( String ) the CoffeeScript code

Returns:

  • ( Object ) — the marker

# (Object) markInsertingCode(code, escape = false, preserve = false, findAndPreserve = false)

Creates a marker for inserting CoffeeScript code that generate an output.

Parameters:

  • code ( String ) the CoffeeScript code
  • escape ( Boolean ) whether to escape the generated output
  • preserve ( Boolean ) when preserve all newlines
  • findAndPreserve ( Boolean ) when preserve newlines within preserved tags

Returns:

  • ( Object ) — the marker

# (void) evaluate()

This method is abstract.

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.

Returns:

  • ( Array ) — all markers

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: