Print Friendly

Class YAHOO.ext.DomHelper.Template

Package:YAHOO.ext
Class:DomHelper.Template
Extends:Object
Defined In:DomHelper.js
Represents an HTML fragment template. For more information see this blog post with examples.
This class is also available as YAHOO.ext.Template.

Public Properties

Property Defined By
  re : RegExp DomHelper.Template
The regular expression used to match template variables

Public Methods

Method Defined By
  DomHelper.Template(String html) DomHelper.Template
  append(HTMLElement el, Object values, [Boolean returnElement]) : HTMLElement DomHelper.Template
Applies the supplied values to the template and append the new node(s) to el
  applyTemplate(Object values) : String DomHelper.Template
Returns an HTML fragment of this template with the specified values applied
  compile() : void DomHelper.Template
Compiles the template into an internal function, eliminating the RegEx overhead
  insertAfter(HTMLElement el, Object values, [Boolean returnElement]) : HTMLElement DomHelper.Template
Applies the supplied values to the template and inserts the new node(s) after el
  insertBefore(HTMLElement el, Object values, [Boolean returnElement]) : HTMLElement DomHelper.Template
Applies the supplied values to the template and inserts the new node(s) before el
  overwrite(HTMLElement el, Object values, [Boolean returnElement]) : HTMLElement DomHelper.Template
Applies the supplied values to the template and overwrites the content of el with the new node(s)

Public Events

This class has no public events.

Property Details

re

public RegExp re
The regular expression used to match template variables
This property is defined by DomHelper.Template.

Constructor Details

DomHelper.Template

public function DomHelper.Template(String html)
Parameters:
  • html : String
    The HTML fragment

Method Details

append

public function append(HTMLElement el, Object values, [Boolean returnElement])
Applies the supplied values to the template and append the new node(s) to el
Parameters:
  • el : HTMLElement
    The context element
  • values : Object
    The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
  • returnElement : Boolean
    (optional) true to return a YAHOO.ext.Element
Returns:
  • HTMLElement
    The new node
This method is defined by DomHelper.Template.

applyTemplate

public function applyTemplate(Object values)
Returns an HTML fragment of this template with the specified values applied
Parameters:
  • values : Object
    The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
Returns:
  • String
This method is defined by DomHelper.Template.

compile

public function compile()
Compiles the template into an internal function, eliminating the RegEx overhead
Parameters:
  • None.
Returns:
  • void
This method is defined by DomHelper.Template.

insertAfter

public function insertAfter(HTMLElement el, Object values, [Boolean returnElement])
Applies the supplied values to the template and inserts the new node(s) after el
Parameters:
  • el : HTMLElement
    The context element
  • values : Object
    The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
  • returnElement : Boolean
    (optional) true to return a YAHOO.ext.Element
Returns:
  • HTMLElement
    The new node
This method is defined by DomHelper.Template.

insertBefore

public function insertBefore(HTMLElement el, Object values, [Boolean returnElement])
Applies the supplied values to the template and inserts the new node(s) before el
Parameters:
  • el : HTMLElement
    The context element
  • values : Object
    The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
  • returnElement : Boolean
    (optional) true to return a YAHOO.ext.Element
Returns:
  • HTMLElement
    The new node
This method is defined by DomHelper.Template.

overwrite

public function overwrite(HTMLElement el, Object values, [Boolean returnElement])
Applies the supplied values to the template and overwrites the content of el with the new node(s)
Parameters:
  • el : HTMLElement
    The context element
  • values : Object
    The template values. Can be an array if your params are numeric (i.e. {0}) or an object (i.e. {foo: 'bar'})
  • returnElement : Boolean
    (optional) true to return a YAHOO.ext.Element
Returns:
  • HTMLElement
    The new node
This method is defined by DomHelper.Template.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.