Base Module for HTML Templates
This module defines filter functions for HTML templates, for use with lb.base.template.applyFilters(input...,filters):any in the base template module.
HTML filters are applied to DOM nodes, which get modified in place. In order to keep the original template for reuse with a different set of values, the node should be cloned before HTML filters are applied.
Eric Bréchemier © 2011-2013, Some Rights Reserved Legal-Box SAS © 2010-2011, All Rights Reserved
BSD License http://creativecommons.org/licenses/BSD/
2013-09-10
lb. | Base Module for HTML Templates |
Functions | |
topDownParsing(node[,context...],filters) | Apply filters recursively to attributes and child nodes. |
replaceParams(getValue): function | Get a filter function to replace parameters in attribute and text nodes. |
Apply filters recursively to attributes and child nodes.
The attributes are processed first (the order is browser-dependent), then child nodes are processed in a depth-first recursion.
node | DOM Node, a DOM node. Only elements are processed by this filter, other nodes are left untouched. |
context... | any, optional, variable number of parameters providing context to the transformation. All context arguments are forwarded in recursive calls to applyFilters(). |
filters | array of functions, the list of filter functions to be applied recursively. This argument is required and always last, which allows filter functions applied to any number of context arguments to omit it in their declaration. |
In Internet Explorer, lots of attribute nodes are present with a default value. Only attributes explicitly defined in the document or through JavaScript are processed: attributes that do not have ‘specified’ property set to true are ignored.
specified | Interface Attr http://www.w3.org |
Get a filter function to replace parameters in attribute and text nodes.
This method applies replaceParams() from the base string templates module, and follows the same conventions:
See details of parameter format in lb.base.template.string.replaceParams(getValue): function.
getValue | function, a getter function returning values for the replacement of parameters: |
function(name): any
The name argument is the name of the parameter to replace. The getter value should return string values when a matching property is found, and null otherwise.
Function: filter(htmlNode) Replace parameters in attribute and text nodes with corresponding values returned by getValue(). The replacements are operated in place in given node. Parameters: htmlNode - DOM Node, a DOM node. Only attribute and text nodes are considered for parameter replacement. Other nodes are left untouched.