company logo

HTML templates

In case of HTML templates, however, text included in the function requires special treatment, because characters as < or > need to be converted.

This is automatically done, when defining an HTML template as shown below:

When converting HTML templates to OSI functions, all text read from the database is converted to HTML by replacing reserved characters (see below)

The difference is in calling the SystemClass :: WriteResult() f unction, which passes true as second parameter to indicate HTML conversion.

  <template>

    <header> string Test() </header>

    <processing>

      <body>

Dear $if (sex == "male")$Mr. $else$Mrs. $end$ $family_name$,

We just got your question concerning $product$, which you are using

since $buying_date$. We have forwarded you problem to

$responsible(0).first_name$ $responsible(0).second_name$.

You will get an response during the next three days. <br/>

      </body>

      $return TemplateString$

    </processing>

  </template>

// will be converted to

function string Test () {

PROCESS

   WriteResult("    <body>\nDear ",false);

   if (sex == "male")

     WriteResult("Mr. "",false);

   else

     WriteResult("Mrs. ",false);

   WriteResult(family_name,true);

   WriteResult(",\n",false);

   WriteResult("We just got your question concerning ",false);

   WriteResult(product,true);

   WriteResult(", which you are using\n since ",false);

   WriteResult(buying_date,true);

   WriteResult(". We have forwarded you problem to \n",false);

   WriteResult(responsible(0).first_name,true);

   WriteResult(" ",false);

   WriteResult(responsible(0).second_name,true);

   WriteResult(".\n You will get an response during the next three days. <br/>\n    </body>";

   return TemplateString;

}

Special characters

The rules for reserved template characters are the same as for ASCII templates, i.e. you must escape all special characters ($ or n), which are supposed to appear as such, in the fixed text.

Special HTML characters in the fixed text must be defined in an HTML conform way (e.g. &lt; for <). Transformations are done only for the text read from the database.

In order to suppress HTML conversion, one may define an ASCII template instead. In order to suppress HTML conversion partially, one may modify the generated function code or define an explicit function.

New lines

New lines do not have any effect on the generated HTML page, but may make the generated code more readable. The template does not create line breaks <br/> or paragraphs <p> from new lines. Those must be defined explicit in the fixed text as all the other HTML tags.