public class Template extends Object
Constructor and Description |
---|
Template(String html)
Creates a new template with the given html.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public Template(String html)
html
- the HTML fragment or an arraypublic Element append(Element el, Object... values)
el
- the context elementvalues
- the positional template valuespublic Element append(Element el, LegacyParams values)
el
- the context elementvalues
- the template valuespublic String applyTemplate(JavaScriptObject values)
values
- the substitution valuespublic String applyTemplate(LegacyParams values)
values
- the valuespublic void compile()
public Element create(Object... values)
values
- the substitution valuespublic Element create(LegacyParams values)
values
- the substitution valuespublic String getHtml()
public ModelStringProvider<ModelData> getStringProvider()
public Element insert(Element el, int index, LegacyParams values)
el
- the context elementindex
- the insert indexvalues
- the valuespublic Element insertAfter(Element el, LegacyParams params)
el
- the context elementparams
- the valuespublic Element insertBefore(Element el, LegacyParams values)
el
- the context elementvalues
- the valuespublic Element insertFirst(Element el, LegacyParams values)
el
- the context elementvalues
- the valuespublic Element overwrite(Element el, LegacyParams values)
el
- the context elementvalues
- the valuespublic Element overwrite(Element el, JavaScriptObject values)
el
- the context elementvalues
- the valuespublic void set(String html, boolean compile)
html
- the html fragmentcompile
- true to compile
public void setStringProvider(ModelStringProvider<ModelData> stringProvider)
stringProvider
- the string providerCopyright © 2015. All rights reserved.