doc • webpage

WebPage Syntax

WebPage are HTML pages that support an extended ASP-like syntax to mix HTML and Gambas code.

New: Tryout the web page playground:

A WebPage is translated into a unique function that prints the HTML to the standard output and executes the included Gambas code 'as is'.

As a WebPage is rendered by an unique function, only local variables can be declared, and only at the top of the page, before any HTML code.

The supported syntaxes are the following:


<%Code%> Any Gambas code that will be executed 'as is'.
<%=Expression%> A Gambas expression that will be converted to HTML with the Html$ function.
<%--Comment--%> A WebPage comments that will be completely ignored, whereas normal HTML comments are emitted.
<%/%> A shortcut for <%=Application.Root%>.
<<WebPage [ Arg1_="_Value1_" , _Arg2_="_Value2_" ... ]>> Include another WebPage into the current WebPage. The syntax is similar to an HTML markup.
<%!Arg%> Insert the value of an argument passed to the <<WebPage>> markup.
<<--CONTENTS-->> Mark the limit between the header and the footer inside the included WebPage.
<</WebPage>> Insert the footer of the included WebPage.


Here is the main WebPage:


<<Page title="Gambas WebPage Example">>
  <h2>Gambas WebPage are easy!</h2>
  <h2>Time is <%=Format(Now, "hh:nn:ss")%></h2>

And here is the included WebPage:


<html xmlns="">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <link rel="stylesheet" href="<%/%>/style.css">
  <link rel="icon" href="<%/%>/img/icon.png" type="image/png">