Aloe Express Methods

ArgsToDictionary

Converts an array of command line arguments (strings) to a Xojo.Core.Dictionary. This method is used by the Server.Constructor method to set server properties based on command line arguments.

Example:

Dim Arguments As Xojo.Core.Dictionary = ArgsToDictionary(Args)

BlockGet

Gets the content between two tokens.

BlockReplace

Replaces the content between two tokens. This can be helpful when applying display logic to a template.

For example:

// If the request indicated that the orders table should be hidden...
Dim HideOrders As String = Request.GET.Lookup("hideorders", "false")
If HideOrders = "true" Then
  
  // Use the Template's BlockReplace method to replace the table.
  Dim TokenBegin As String = "{{! Orders Table - Begin }}"
  Dim TokenEnd As String = "{{! Orders Table - End }}"
  Template.Source = Template.BlockReplace(Template.Source, TokenBegin, TokenEnd, 0, "")
  
Else
  
  // Use the Template's BlockReplace method to replace the "orders hidden" message.
  Dim TokenBegin As String = "{{! Orders Hidden - Begin }}"
  Dim TokenEnd As String = "{{! Orders Hidden - End }}"
  Template.Source = Template.BlockReplace(Template.Source, TokenBegin, TokenEnd, 0, "")
  
End If

DateToRFC1123

Converts a Xojo.Core.Date to a RFC 822 / 1123 formatted text value. For example: Mon, 27 Nov 2017 13:27:26 GMT Special thanks to Xojo's Norman Palardy for providing this method.

Example:

// Get the current time in RFC1123 format.
Dim Now As String = AloeExpress.DateToRFC1123(Xojo.Core.Date.Now)

DictionaryToJSONItem

Converts a standard Xojo dictionary to a JSON object (JSONItem).

DictionaryToJSONString

Converts a standard Xojo dictionary to a JSON string.

FileRead

Given a FolderItem, this method will attempt to read the file, and if successful, returns its contents.

Beginning with Aloe Express v3.0, the FileRead method now takes an optional TextEncoding parameter. The default is UTF8.

Example:

// Create a folderitem that points to the template file.
Dim FI as FolderItem = Request.StaticPath.Child("index.html")

// Use Aloe's FileRead method to load the file.
HTML = AloeExpress.FileRead(FI)

Gunzip

Decompresses content that has been compressed (gzipped).

Gzip

Compresses (gzips) content. Special thanks to John Hansen for sharing this technique.

Example:

Content = GZip(Content)

JSONStringToJSONItem

Converts a JSON string to a JSON object (JSONItem).

MIMETypeGet

Maps a file extension to its MIME type. If no matching MIM type is found, "binary/octet-stream" is returned. Based in large part on Samuel Neff's MimeTypeMap.

Example:

Request.Response.Headers.Value("Content-Type") = AloeExpress.MIMETypeGet("pdf")

PrimitiveToString

Converts the value of a primitive datatype (boolean, number, string, etc) to a string.

RecordSetToJSONItem

Converts a recordset to JSONItem.

TextToString

Converts a text value to a string.

URLDecode

Decodes a URL-encoded value.

URLEncode

URL-encodes a value. This method is a wrapper for Xojo's EncodeURLComponent, and is provided for consistency and convenience.

UUIDGenerate

Generates a UUID. Special thanks to Roberto Calvi for providing this code.

VersionString

Returns the Aloe Express version as a string.