com.sencha.gxt.legacy.client.core
Class Template

java.lang.Object
  extended by com.sencha.gxt.legacy.client.core.Template

public class Template
extends Object

Represents an HTML fragment template. Templates can be precompiled for greater performance.


Constructor Summary
Template(String html)
          Creates a new template with the given html.
 
Method Summary
 Element append(Element el, LegacyParams values)
          Applies the supplied values to the template and appends the new node(s) to el.
 Element append(Element el, Object... values)
          Applies the supplied values to the template and appends the new node(s) to el.
 String applyTemplate(JavaScriptObject values)
          Returns an HTML fragment of this template with the specified values applied.
 String applyTemplate(LegacyParams values)
          Returns an HTML fragment of this template with the specified values applied.
 void compile()
          Compiles the template into an internal function, eliminating the regex overhead.
 Element create(LegacyParams values)
          Creates a new element.
 Element create(Object... values)
          Creates a new element.
 String getHtml()
           
 ModelStringProvider<ModelData> getStringProvider()
          Returns the template's string provider.
 Element insert(Element el, int index, LegacyParams values)
          Applies the supplied values to the template and inserts the new node(s) at the given index.
 Element insertAfter(Element el, LegacyParams params)
          Applies the supplied values to the template and inserts the new node(s) after el.
 Element insertBefore(Element el, LegacyParams values)
          Applies the supplied values to the template and inserts the new node(s) before el.
 Element insertFirst(Element el, LegacyParams values)
          Applies the supplied values to the template and inserts the new node(s) as the first child of el.
 Element overwrite(Element el, JavaScriptObject values)
          Applies the supplied values to the template and overwrites the content of el with the new node(s).
 Element overwrite(Element el, LegacyParams values)
          Applies the supplied values to the template and overwrites the content of el with the new node(s).
 void set(String html, boolean compile)
          Sets the HTML used as the template and optionally compiles it.
 void setStringProvider(ModelStringProvider<ModelData> stringProvider)
          Sets the string provider for the template.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Template

public Template(String html)
Creates a new template with the given html.

Parameters:
html - the HTML fragment or an array
Method Detail

append

public Element append(Element el,
                      Object... values)
Applies the supplied values to the template and appends the new node(s) to el.

Parameters:
el - the context element
values - the positional template values
Returns:
the new element

append

public Element append(Element el,
                      LegacyParams values)
Applies the supplied values to the template and appends the new node(s) to el.

Parameters:
el - the context element
values - the template values
Returns:
the new element

applyTemplate

public String applyTemplate(JavaScriptObject values)
Returns an HTML fragment of this template with the specified values applied.

Parameters:
values - the substitution values
Returns:
the html frament

applyTemplate

public String applyTemplate(LegacyParams values)
Returns an HTML fragment of this template with the specified values applied.

Parameters:
values - the values
Returns:
the html fragment

compile

public void compile()
Compiles the template into an internal function, eliminating the regex overhead.


create

public Element create(Object... values)
Creates a new element.

Parameters:
values - the substitution values
Returns:
the new element

create

public Element create(LegacyParams values)
Creates a new element.

Parameters:
values - the substitution values
Returns:
the new element

getHtml

public String getHtml()

getStringProvider

public ModelStringProvider<ModelData> getStringProvider()
Returns the template's string provider.

Returns:
the string provider

insert

public Element insert(Element el,
                      int index,
                      LegacyParams values)
Applies the supplied values to the template and inserts the new node(s) at the given index.

Parameters:
el - the context element
index - the insert index
values - the values
Returns:
the new element

insertAfter

public Element insertAfter(Element el,
                           LegacyParams params)
Applies the supplied values to the template and inserts the new node(s) after el.

Parameters:
el - the context element
params - the values
Returns:
the new element

insertBefore

public Element insertBefore(Element el,
                            LegacyParams values)
Applies the supplied values to the template and inserts the new node(s) before el.

Parameters:
el - the context element
values - the values
Returns:
the new element

insertFirst

public Element insertFirst(Element el,
                           LegacyParams values)
Applies the supplied values to the template and inserts the new node(s) as the first child of el.

Parameters:
el - the context element
values - the values
Returns:
the new element

overwrite

public Element overwrite(Element el,
                         LegacyParams values)
Applies the supplied values to the template and overwrites the content of el with the new node(s).

Parameters:
el - the context element
values - the values
Returns:
the new element

overwrite

public Element overwrite(Element el,
                         JavaScriptObject values)
Applies the supplied values to the template and overwrites the content of el with the new node(s).

Parameters:
el - the context element
values - the values
Returns:
the new element

set

public void set(String html,
                boolean compile)
Sets the HTML used as the template and optionally compiles it.

Parameters:
html - the html fragment
compile - true to compile

setStringProvider

public void setStringProvider(ModelStringProvider<ModelData> stringProvider)
Sets the string provider for the template.

Parameters:
stringProvider - the string provider


Copyright © 2011. All Rights Reserved.