Class: HamlCoffee
Defined in: | node_modules/haml-coffee/src/haml-coffee.coffee |
Overview
The HamlCoffee class is the compiler that parses the source code and creates an syntax tree.
Constant Summary
-
VERSION
=
The current version number.
-
require('../package.json')
Instance Method Summary
-
.cleanupWhitespace(code)
Adds whitespace cleanup function when needed by the The detection is based on hidden unicode characters that are placed as marker into the template:
\u0091
Cleanup surrounding whitespace to the left\u0092
Cleanup surrounding whitespace to the right @param [String] code the CoffeeScript template code @return [String] the clean up whitespace code if necessary - .combineText(lines) Optimize the lines to be rendered by combining subsequent text @param [Array
- .constructor(options = {}) Constructor Construct the HAML Coffee compiler.
-
.convertBooleans(code)
Adds a boolean convert logic that changes boolean attribute With the XHTML format, an attribute
checked='true'
will be converted tochecked='checked'
andchecked='false'
will be completely removed. - .createCode() Create the CoffeeScript code for the template.
- .evaluate(node) Evaluate the parsed tree @param [Node] node the node to evaluate
- .findDependencies(code) Searches for AMD require statements to find @example CST source code $o.push "" + $c require('assets/templates/test')() => { test: 'assets/templates/test' } @param [String] code the CoffeeScript template source code @return [Object] the module dependencies
- .getBuffer(level) Get the code buffer identifer @param [Number] level the block indention level
- .getNodeOptions(override = {}) Get the options for creating a node @param [Object] override the options to override @return [Object] the node options
- .indentChanged() Test if the indention level has changed, either @return [Boolean] true when indention changed
- .isIndent() Test if the indention levels has been increased.
- .nodeFactory(expression = '') Get the matching node type for the given expression.
- .parse(source = '') Parse the given source and create the nested node Parsing does not create an output, it creates the syntax tree in the compiler.
- .popParent() Indention level has been decreased:
- .precompile() Pre-compiles the parsed source and generates @return [String] the template function source code
- .pushParent() Indention level has been increased:
- .removeEmptyIDAndClass(code) Remove empty ID and class attribute from the @param [String] code the CoffeeScript template code @return [String] the template code with the code added
- .render() Render the parsed source code as CoffeeScript template.
- .renderAmd() Render the parsed source code as CoffeeScript template wrapped in a @private @return [String] the CoffeeScript template source code
- .renderGlobal() Render the parsed source code as CoffeeScript template to a global @private @return [String] the CoffeeScript template source code
- .renderStandalone() Render a standalone version
- .updateBlockLevel() Update the current block level indention.
- .updateCodeBlockLevel(node) Update the indention level for a code block.
- .updateParent() Update the parent node.
- .updateTabSize() Calculate the indention size
Constructor Details
.constructor(options = {})
Construct the HAML Coffee compiler.
@param [Object] options the compiler options
@option options [String] placement where to place the resultant function
@option options [Arrayxhtml
, html4
or html5
@option options [String] hyphenateDataAttrs whether to convert underscores to hyphens in data attributes
@option options [String] preserveTags a comma separated list of tags to preserve content whitespace
@option options [String] selfCloseTags a comma separated list of self closing HTML tags
@option options [String] customHtmlEscape the name of the function for HTML escaping
@option options [String] customCleanValue the name of the function to clean code insertion values before output
@option options [String] customFindAndPreserve the name of the function used to find and preserve whitespace
@option options [String] customPreserve the name of the function used to preserve the whitespace
@option options [String] customReference the name of the function used to create the id from object references
Instance Method Details
.cleanupWhitespace(code)
Adds whitespace cleanup function when needed by the
The detection is based on hidden unicode characters that are placed as marker into the template:
\u0091
Cleanup surrounding whitespace to the left\u0092
Cleanup surrounding whitespace to the right
@param [String] code the CoffeeScript template code @return [String] the clean up whitespace code if necessary
.combineText(lines)
Optimize the lines to be rendered by combining subsequent text
@param [Array
.convertBooleans(code)
Adds a boolean convert logic that changes boolean attribute
With the XHTML format, an attribute checked='true'
will be
converted to checked='checked'
and checked='false'
will
be completely removed.
With the HTML4 and HTML5 format, an attribute checked='true'
will be converted to checked
and checked='false'
will
be completely removed.
@param [String] code the CoffeeScript template code @return [String] the clean up whitespace code if necessary
.createCode()
Create the CoffeeScript code for the template.
This gets an array of all lines to be rendered in the correct sequence.
@return [String] the CoffeeScript code
.evaluate(node)
Evaluate the parsed tree
@param [Node] node the node to evaluate
.findDependencies(code)
Searches for AMD require statements to find
@example CST source code $o.push "" + $c require('assets/templates/test')() => { test: 'assets/templates/test' }
@param [String] code the CoffeeScript template source code @return [Object] the module dependencies
.getBuffer(level)
Get the code buffer identifer
@param [Number] level the block indention level
.getNodeOptions(override = {})
Get the options for creating a node
@param [Object] override the options to override @return [Object] the node options
.indentChanged()
Test if the indention level has changed, either
@return [Boolean] true when indention changed
.isIndent()
Test if the indention levels has been increased.
@return [Boolean] true when increased
.nodeFactory(expression = '')
Get the matching node type for the given expression. This
@param [String] expression the HAML expression @return [Node] the parser node
.parse(source = '')
Parse the given source and create the nested node
Parsing does not create an output, it creates the syntax tree in the
compiler. To get the template, use #render
.
@param [String] source the HAML source code
.popParent()
Indention level has been decreased:
.precompile()
Pre-compiles the parsed source and generates
@return [String] the template function source code
.pushParent()
Indention level has been increased:
.removeEmptyIDAndClass(code)
Remove empty ID and class attribute from the
@param [String] code the CoffeeScript template code @return [String] the template code with the code added
.render()
Render the parsed source code as CoffeeScript template.
.renderAmd()
Render the parsed source code as CoffeeScript template wrapped in a
@private @return [String] the CoffeeScript template source code
.renderGlobal()
Render the parsed source code as CoffeeScript template to a global
@private @return [String] the CoffeeScript template source code
.renderStandalone()
Render a standalone version
.updateBlockLevel()
Update the current block level indention.
.updateCodeBlockLevel(node)
Update the indention level for a code block.
@param [Node] node the node to update
.updateParent()
Update the parent node. This depends on the indention
.updateTabSize()
Calculate the indention size