Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
About The Best Formula In The World
Architecture details
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Image Management In Gambas
Including Help Comments in Source Code
Interpreter limits
Just In Time Compiler
Just In Time Compiler (old version)
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Search the wiki
To Do
Wiki License
Wiki Manual

WebPage Syntax

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

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:

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.


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">