Velocity markup

From Hostcontrol Wiki
Jump to: navigation, search

General overview

The template engine used to render the templates is Velocity, a summery of the most common syntax is listed below, the full documentation can be found in the [|Velocity user guide].

Please note all variable access and syntax is case sensitive.

Variables and notation

Variables are referenced with a dollar sign ($) followed by the variable name between curly brackets ({}). The use of the curly brackets is optional in most cases, one exception is when the boundary between the variable and the next word is not clear.

When a variable does not exist or does not have a value the tag is not replaced, by adding a exclamation mark (!) after the dollar sign the variable will be silently ignored. A few code examples are below

__Template__

Full notation: ${brand.organization}
Short notation: $brand.organization
Undefined field: $brand.fax
Undefined field, silent: $!brand.fax

__Output__

Full notation: Organization
Short notation: Organization
Undefined field: $brand.fax
Undefined field, silent:

If / Else statement

The #if directive allows for text to be included, on the conditional that the if statement is true. For example:

__Template__

#if( $brand.fax )
Fax number: $brand.fax
#else
No fax number available
#end

__Output__
No fax number available

Foreach loop

The #foreach element allows for looping over lists. A loop counter is provided in the variable $counter, the counter starts at 1.

__Template__

#foreach( $addressLine in $brand.addressLines )
Address line $counter: $addressLine
#end

__Output__
Address line 1: Address

Common objects in branding

For the above templates, some extensions on top of the basic function (calling an object) is available. These are listed below.

Country

$country.code<: ISO 3166-1 Alpha2 country code
$country.name

Brand

The Brand object itself will output the brand's organization, other attributes available are:

$brand.organization
$brand.addressLines: List of address lines
$brand.addressLine: The first address line for easy access
$brand.postalCode
$brand.city
$brand.state: Optional
$brand.country: __Country__ object
$brand.email
$brand.voice
$brand.fax: Optional
$brand.url: Optional

Contact

The Contact object itself will output the contact's organization if present, otherwise the contact's name, other attributes available are:

$contact.handle
$contact.name
$contact.organization: Optional
$contact.addressLines: List of address lines
$contact.addressLine: The first address line for easy access
$contact.postalCode
$contact.city
$contact.state: Optional
$contact.country: Country object</code>
$contact.email
$contact.voice
$contact.fax: Optional

DomainContact

The domainContact object itself will the contact's role and organization if present otherwise the contact's name, other attributes available are:

$domainContact.role: The contact's role (ADMIN, BILLING or TECH)
$domainContact.contact: Contact object

Domain

The Domain object itself will output the domains idn domain name, other attributes available are:

$domain.domainName: Punicode notation in case of IDN domain name
$domain.idnDomainName: Unicode notation in case of IDN domain name
$domain.registrant: Contact object
$domain.contacts: Optional, list DomainContact objects
$domain.admin: Optional, list of Contact objects with ADMIN role
$domain.billing: Optional, list of Contact objects with BILLING role
$domain.tech: Optional, list of Contact objects with TECH role
$domain.ns: Optional, list of name servers
$domain.childHosts: Optional, list of child hosts
$domain.createdDate
$domain.expiryDate
$domain.updatedDate: Optional
$domain.languageCode: Optional

Objects available per template

WEB HEADER, EMAIL HEADER, EMAIL FOOTER, EMAIL HEADER


$brand is available for every template. This is the only template available for footers and headers, but quite detailed (see below)

ERRP MONTH and ERRP WEEK


$domain: Domain object with current domain details
$days: Number of days until the expiry date of the domain name

INCOMING FOA, INCOMING FOA AND VALIDATION, INTERNAL FOA


$transfer: Domain object with transfer request details
$requestDate: The date the transfer request was made

VALIDATE CONTACT


$contact: Contact object with contact details
$validity: The date until this validation request is valid
$domainNames: List of domain names pending on this contact validation

PENDING VALIDATION


$domain: Domain object with current domain details</code>