wwResponse::ExpandTemplate

The ExpandTemplate method is used to expand template pages that contain FoxPro expressions using Active Server like syntax. The method generates a fully self contained HTML page/HTTP output which includes an HTTP header.

The template syntax allowed is simple and looks as follows:

<%= Version() %>
<%= Table.FieldName %>
<%= MyUDF() %>
<%= PrivateVar %>
<%= Class.Property %>

or

<%
Code Block (any valid procedural FoxPro code)
%>

Expressions are expanded prior to sending the document back to the client, so expressions are valid anywhere inside of the HTML document including in HTML field values and HREF links etc.

o.ExpandTemplate(lcPageName, lcContentType, llTemplateString, llNoOutput)

Return Value

"" or HTML string if llNoOutput is .T.

Parameters

lcPageName
Fully qualified filename of the template to expand from disk.
Optionally, this may be a string containing the actual script if the llTemplateString parameter is set to .T.

lvContentType
Optional - Either an wwHTTPHeader object or content type string. See wwHTTPHeader class for info.

llTemplateString
Optional - If passed .T. it indicates that lcPageName was passed as the actual template string, rather than the filename.

llNoOutput
Optional - if .T. output is returned to string and no HTTP stream output is created

Remarks

Since embedded code blocks (ie. more than one line of code using <% %>) are dynamically evaluated through macro expansion you'll want to keep the use of functions to a minimum for speed reasons. If you use excessive functions in your pages I would highly recommend you build a custom Processing routine as a UDF instead of building the code into an HTML page. Custom code is much easier to debug and maintain and also runs a lot faster since no on the fly evaluation takes place.

Example

Response.ExpandTemplate(THIS.cHTMLPagePath + "node.wc")

See also:

Class wwResponse | wwResponse::ContentTypeHeader | wwResponse::ExpandScript | wwUtils::MergeText | wwEval::MergeText

© West Wind Technologies, 1996-2018 • Updated: 11/26/15
Comment or report problem with topic