Class CSPTemplate

Description
This class manipulates HTML template files, in which you can insert text or you can recursively reproduce some parts of the template.

Member functions: Member variables:

Remarks:
The CSPTemplate class supports "slots" and "containers" in a template. A slot is marked in a template file with a tag of the form <CSP: tag_name/> and you can insert text in its place. A container is marked with an opening and a closing tag of the form <CSP: tag_name> ... text or html code ... </CSP: tag_name>. Usually, a container may contain text and another slots or containers, which can recursively be reproduced. A slot or a container is referenced with it's tag name an can be manipulated throught the CSPTemplate class by using the parenthesis operator() ( const CSPString& ) with the tag name and the member functions Echo() and Echo( const CSPString& ). Every slot or container is represented by a CSPTemplate class. Therefore, a template consists of a root CSPTemplate object, which contains another CSPTemplate objects, each of which may recursively contain another CSPTemplate objects etc, building a tree of CSPTemplate objects. HTML template example:

<TABLE>
<CSP:row>
<TR>
<CSP:cell><TD><CSP:text>(Text placeholder. Could be empty)</CSP:text></TD></CSP:cell>
</TR>
</CSP:row>
</TABLE>

C++ code example:

CSPTemplate t;

t.Build( pszHTMLTemplateCode );

t("row")("cell")("text")="Some text in cell#1, row#1";
t("row")("cell").Echo();

t("row")("cell")("text")="Some text in cell#2, row#1";
t("row")("cell").Echo();

t("row").Echo(); t("row")("cell")("text")="Some text in cell#1, row#2";
t("row")("cell").Echo();

t("row")("cell")("text")="Some text in cell#2, row#2";
t("row")("cell").Echo();

t("row").Echo();

t.Echo();

Response.Write( t );


Other support classes | Class Categories | Online help home | Back

www.micronovae.com

Copyright © 2002 - 2005 Micronovae Ltd