WebPage Syntax
WebPage are HTML pages that support an extended ASP-like syntax to mix HTML and Gambas code.
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:
Syntax
|
Description
|
<%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.
|
Example
Here is the main
WebPage:
Main.webpage
<<Page title="Gambas WebPage Example">>
<h2>Gambas WebPage are easy!</h2>
<h2>Time is <%=Format(Now, "hh:nn:ss")%></h2>
<</Page>>
And here is the included WebPage:
Page.webpage
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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">
<title><%!title%></title>
</head>
<body>
<<--CONTENTS-->>
</body>
</html>