Special HTML Directives
In the OnPage() callback in a CSP page class, you can use the special directive &html<> to write HTML. This directive can be a simpler way to construct HTML, although the result does not lend itself to unit testing (because you cannot examine the result without using a browser).
&html<> Basics
The special directive &html<> can contain any valid HTML, including multiple lines of HTML. For example:
Class GCSP.HTML Extends %CSP.Page
{
ClassMethod OnPage() As %Status
{
&html<<!DOCTYPE html>
<html lang="en" dir="ltr">
<body>
<h1>Basic Page</h1>
<div>No double quotes needed "here"</div>
</body>
</html>>
Quit $$$OK
}
}
Expressions within &html<>
Sometimes it is convenient to include expressions within the HTML contained in the directive &html<>. There are two possibilities:
-
Expressions evaluated at compile time. For this, you can use the following syntax:
##(expression)##
This kind is known as a CSP compile-time expression.
-
Expressions evaluated at run time. For this, you can use the following syntax:
#(expression)#
Where expression is any ObjectScript expression. This kind is known as a CSP run-time expression.
In either case, simply include the syntax at the position where the expression is needed (not performing any sort of concatenation). Here is an example:
Class GCSP.HTML1 Extends %CSP.Page
{
ClassMethod OnPage() As %Status
{
&html<<!DOCTYPE html>
<html lang="en" dir="ltr">
<body>
<h1>Basic Page</h1>
<div>This class was compiled at ##($zdatetime($h,3))##</div>
<div>This class was viewed at #($zdatetime($h,3))#</div>
</body>
</html>>
Quit $$$OK
}
}