-
Notifications
You must be signed in to change notification settings - Fork 29
PKUTIL.instanceOfTemplate
kerrishotts edited this page Nov 14, 2012
·
1 revision
(part of PKUTIL)
Return Type: string of HTML
Parameters: theTemplate ( string / element ), replacements ( dirctionary )
Takes the supplied template, applies all the replacements, and returns a string containing the replacements.
The given template can be either a string or a DOM element. If a DOM element is supplied, the innerHTML
is used as the template string.
The replacements
is a dictionary containing the replacement variables, like so:
var replacements =
{
"text": "replacement",
"needle": "haystack"
}
If given the following string:
This %TEXT% is a %NEEDLE%.
the result would be:
This replacement is a haystack.
For example:
var theHTML = PKUTIL.instanceOfTemplate ( $ge("someElement"),
{ "text": "replacement", "needle": "haystack" } );
The substitution strings should be surrounded by percent signs and capitalized in the template. When in the dictionary, the case doesn't matter.
0.1 Introduced, only supported DOM elements.
0.2 Supports strings as well as DOM elements, Docs Valid