Template
A string template class for Classic ASP.
About
Summary
|
|
A string template class for Classic ASP.
|
|
|
|
|
|
This property holds the current Template value.
|
|
|
This property holds the standard Template separator.
|
|
|
|
|
|
Subroutine to Response.write templates directly from arguments.
|
|
|
Use this method to retrieve an evaluatedversion of the value with the given replacements.
|
|
|
Removes all extraneous whitespace from a string and trims it.
|
|
|
Compute the final length of an evaluated template with the given replacements.
|
|
|
Compute the template and retrieve a lowercased version of it’s value.
|
|
|
Compute the template and retrieve an uppercased version of it’s value.
|
|
|
Compute the template and retrieve a capitalized version of it’s value.
|
|
|
Compute the template and retrieve a camelized version of it’s value.
|
|
|
Compute the template and retrieve a hyphenated version of it’s value.
|
|
|
Look up in the evaluated template for a character at the specified position.
|
|
|
Extracts a specified number of characters in a evaluated template, from a start index.
|
|
|
Extracts the characters in a evaluated template between two specified indices.
|
|
|
Compute the template and look for the position of the first occurence of a specified fragment in the evaluated string.
|
|
|
Compute the template and search for a match between the value and a relular expression.
|
value
This property holds the current Template value.
Contains
separator
This property holds the standard Template separator.
Contains
write
|
public sub write(
|
sTemplate,
|
|
saArgs
|
)
|
|
Subroutine to Response.write templates directly from arguments.
Parameters
|
(string)sTemplate
|
Template with placeholders.
|
|
(string[])saArgs
|
Array with the replacements.
|
Example
' The infamous hello world example using Template.write
dim String : set String = new Template
String.write "{0} {1}", array("Hello", "World")
String.write "{0} {1}", null
set String = nothing
See also
substitute
substitute
|
public function substitute(
|
saArgs
|
)
|
|
Use this method to retrieve an evaluatedversion of the value with the given replacements.
Parameters
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.substitute(array("Hello", "World"))
Response.write String.substitute(null)
set String = nothing
See also
write
clean
|
public function clean(
|
saArgs
|
)
|
|
Removes all extraneous whitespace from a string and trims it.
Parameters
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
A clean evaluated string.
|
Example
dim String : set String = new Template : String.value = "{0} {1}, I like ASP."
Response.write String.clean(array("Hello", "World"))
Response.write String.clean(null)
set String = nothing
length
|
public function length(
|
saArgs
|
)
|
|
Compute the final length of an evaluated template with the given replacements.
Parameters
|
(string[])saArgs
|
Replacements
|
Returns
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.length(array("Hello", "World"))
Response.write String.length(null)
set String = nothing
toLowerCase
|
public function toLowerCase(
|
saArgs
|
)
|
|
Compute the template and retrieve a lowercased version of it’s value.
Parameters
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Lowercased evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.toLowerCase(array("Hello", "World"))
Response.write String.toLowerCase(null)
set String = nothing
See also
toUpperCase, capitalize, camelize, hyphenate
toUpperCase
|
public function toUpperCase(
|
saArgs
|
)
|
|
Compute the template and retrieve an uppercased version of it’s value.
Parameters
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Uppercased evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.toUpperCase(array("Hello", "World"))
Response.write String.toUpperCase(null)
set String = nothing
See also
toLowerCase, capitalize, camelize, hyphenate
capitalize
|
public function capitalize(
|
cSeparator,
|
|
saArgs
|
)
|
|
Compute the template and retrieve a capitalized version of it’s value.
Parameters
|
(char)cSeparator
|
Separator (OPTIONAL)
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Capitalized evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.capitalize(, array("hello", "world"))
Response.write String.capitalize(" ", null)
set String = nothing
See also
toLowerCase, toUpperCase, camelize, hyphenate
camelize
|
public function camelize(
|
cSeparator,
|
|
saArgs
|
)
|
|
Compute the template and retrieve a camelized version of it’s value.
Parameters
|
(char)cSeparator
|
Separator (OPTIONAL)
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Camelized evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.camelize(, array("Hello", "World"))
Response.write String.camelize(" ", null)
set String = nothing
See also
toLowerCase, toUpperCase, capitalize, hyphenate
hyphenate
|
public function hyphenate(
|
cSeparator,
|
|
saArgs
|
)
|
|
Compute the template and retrieve a hyphenated version of it’s value.
Parameters
|
(char)cSeparator
|
Separator (OPTIONAL)
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Hyphenated evaluated string
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.hyphenate(, array("Hello", "World"))
Response.write String.hyphenate(" ", null)
set String = nothing
See also
toLowerCase, toUpperCase, capitalize, camelize
charAt
|
public function charAt(
|
i,
|
|
saArgs
|
)
|
|
Look up in the evaluated template for a character at the specified position.
Parameters
|
(int)i
|
Index
|
|
(string[])saArgs
|
Replacements
|
Returns
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.contains(0, array("Hello", "World"))
set String = nothing
substr
|
public function substr(
|
iStart,
|
|
iLength,
|
|
saArgs
|
)
|
|
Extracts a specified number of characters in a evaluated template, from a start index.
Parameters
|
(int)iStart
|
Where to start the extraction
|
|
(int)iLength
|
How many characters to extract (OPTIONAL)
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Evaluated string fragment
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.substr(0, 5, array("Hello", "World"))
Response.write String.substr(6,, array("Hello", "World"))
set String = nothing
substring
|
public function substring(
|
iStart,
|
|
iStop,
|
|
saArgs
|
)
|
|
Extracts the characters in a evaluated template between two specified indices.
Parameters
|
(int)iStart
|
Where to start the extraction
|
|
(int)iStop
|
WHere to stop the extraction (OPTIONAL)
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(string)
|
Evaluated string fragment
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.substr(0, 2, array("Hello", "World"))
Response.write String.substr(6,, array("Hello", "World"))
set String = nothing
contains
|
public function contains(
|
sFragment,
|
|
saArgs
|
)
|
|
Compute the template and look for the position of the first occurence of a specified fragment in the evaluated string.
Parameters
|
(string)sFragment
|
Fragment to look for
|
|
(string[])saArgs
|
Replacements
|
Returns
|
(int)
|
The position of the first occurence of the fragment within value
|
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.contains("Hello", array("Hello", "World"))
Response.write String.contains("World", array("Hello", "World"))
Response.write String.contains("Lorem ipsum", array("Hello", "World"))
set String = nothing
test
|
public function test(
|
sPattern,
|
|
bIgnoreCase,
|
|
bGlobal,
|
|
saArgs
|
)
|
|
Compute the template and search for a match between the value and a relular expression.
Parameters
|
(string)sPattern
|
String representation of the regular expression
|
|
(bool)bIgnoreCase
|
true|false indicating to enable a CI search or not
|
|
(bool)bGlobal
|
true|false indicating to match or not all occurrences of the pattern
|
Returns
true, if a match for the regular expression is found in the value false, otherwise
Example
dim String : set String = new Template : String.value = "{0} {1}"
Response.write String.test("Hello", false, true, array("Hello", "World"))
Response.write String.test("hello", true, true, array("Hello", "World"))
set String = nothing
|