Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
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
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
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
Screenshots
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
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
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: https://gambas.one/playground/web.php

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>