HCML documentation

<page>

Create a new page in your prototype responding to a given URL.

Attributes:

url
Required. Specifies a relative URL beginning with '/' at which this page will be made available in your prototype.
type
Optional. Determines what type of page this is. Values allowed: xml, html, html5, xhtml, css, js, text. If not specified, the page will output HTML without a doctype, resulting in a quirks mode HTML page.
method
Optional. Use if you want to respond to a specific kind of request. Values allowed: post or get.
layout
Optional. Use if you want this page to use a <layout> you specified elsewhere. You must refer to the layout by its name attribute. If a page uses a layout, the only immediate children allowed within it are <part>s.

<layout>

Create a new layout which can be reused by pages in your prototype.

Attributes:

name
Required. A name by which <page>s can refer to this layout. The name must be one single word consisting of A-Z or 0-9 characters.
type
Optional. Identical to <page>'s type attribute.

<part>

Create a new reusable part which can be used anywhere with the <write> tag.
<part> is also used when creating a page using a layout. In that case, <part> is used to indicate which parts of the layout are being filled.
When a <write> tag is writing this part, it can pass XML data. The part can act on that data as if it was its current context.

Attributes:

name
Required. A name by which you can refer to this part when using it with <write> or inside a <page> using a layout.

<write>

Write a part, variable or value to the page at the location of the tag.
This tag requires one (and only one) of the below attributes.
Passing data to a part is as simple as putting arbitrary XML in between the <write> open and close tags.

Attributes:

value
Write something to the page.
  • Enclose the value with single quotes to write a string to the page.
    For instance, <write value="'Hi!'" />.
  • Use $ to refer to a <var>. For instance, <write value="$MyVar" />.
  • If used within a <for each> tag, value may refer to the current XPath node.
part
Write the content of any part to the page by its name.
xml
Advanced Writes XML of a <var> to the page. For instance:
<var name="data">
  <p>Hello world.</p>
</var>
<write xml="$data/*"/>

<var>

Create a named variable with a value, which can be written to the page using <write>.
Reference using $, for instance $MyVar.

Attributes:

name
Required. The name by which this variable will be referred to.
value
Optional. The value the variable contains. This attribute can be ignored if the variable is set to contain XML.

<what if>

If what is specified in the if attribute is true, the code inside this tag will be executed or drawn.

Attributes:

if
Required. Specifies the equation to evaluate in order to determine whether the content of the <what> tag should be executed or drawn. If the result is false, nothing will happen unless the <what> tag is followed immediately by an <else> tag, in which case the <else> tag's contents will be executed.

<else>

Used exclusively with <what if>. If the code in the <what if> doesn't result in true, the code in this tag will be executed.

Attributes:

None.

<for each>

Loop through some data and do something with each item. Used in combination with <var>.

Attributes:

each
Required. Specifies which variable and XPath should be used in the loop. For instance, looping over $employees/person would make the person tag in the $employees <var> available inside each iteration of the loop.
dir
The direction to order by, either ascending or descending. Defaults to ascending.
orderby
The XPath to order by.

<do action>

Performs an action by executing a function. Only a few of the functions can be "done"; those that can will be displayed by quplo's code completion.

Attributes:

action
Required. Specifies the action to perform by executing a given function.

<attr>

Adds an attribute to its containing element. The value within the attr tag is the value for the attribute.

Attributes:

name
Required. Specifies the name of the attribute.

Global variables

We've made several useful variables available throughout your prototypes that you can use to access data you wouldn't otherwise be able to in vanilla HTML.

Variables:

$browser
A global variable that holds information about the browser used to access the prototype. The data can be accessed using XPath, for instance $browser/@major.
$get
A global variable that holds any GET information that has been sent to the current page. The data can be accessed using XPath, for instance $get/search if the URL is ?search=123.
$post
A global variable that holds any POST information that has been sent to the current page. The data can be accessed using XPath, for instance $post/username if a form was posted containing a field with name "username".
$context
A global variable that holds information about the current http request, such as the url path that is being surfed to. The data can be accessed using XPath, for instance $context/path.

Functions

Various ways to work with your page content, such as lowercase(), substring() or login().

Note: these functions are advanced features of HCML, intended for those with programming experience!

Functions and their arguments

contains(str, substr)
Determines whether the given str contains the string substr. If it does, the result will be true, otherwise it will be false.
endswith(str, char)
Determines whether str ends with char. If it does, the result will be true, otherwise it will be false.
even()
If the position of the current node is even, the result will be true, otherwise it will be false.
get(name)
Retrieve a value (can be XML) from the session by its name.
if(eval, doIf, doElse)
Allows you to execute a conditional evaluation. eval will be evaluated, for instance 1 = 1, and if the result is true, doIf will be executed, otherwise doElse will be executed.
indexof(str, char)
Outputs the position of char within str. -1 if char is not found.
join(str, str2)
Combines str with str2 and outputs the result.
length(str)
Outputs a number equalling the length of the given str.
loggedin()
Determines whether the current browser session is logged in.
login()
Logs the current browser session in. Login status can be retrieved with loggedin().
logout()
Logs the current browser session out. Login status can be retrieved with loggedin().
loop(from, to)
Loops from the number from until the number to. For example, loop(1,5) will loop 5 times.
lowercase(str)
Output the given str in lower case.
now(format)
Tells you the current date and time. Optionally you can use format to specify how you want the date and time formatted using standard date formatting notation.
odd()
If the position of the current node is odd, this function will return true.
pagenotfound()
Tells the browser requesting the page that the page could not be found. A 404 status code is returned.
redirect(url)
Redirects the page to the given url. For example: redirect('/')
regex(str, expr)
Tests the given str for the given regular expression. If the expression is found, the result will be true, otherwise it will be false.
replace(str, find, replace)
Searches the given str for find and replaces it with replace.
set(name, value)
Store a value (can be XML) in the current session by its name.
split(str, index)
Outputs the remaining value after index in str.
startswith(str, char)
Determines whether str starts with char.
substring(str, pos1, pos2)
Outputs the substring from pos1 until pos2 in str.
uppercase(str)
Output the given str in upper case.
url(str)
Converts the given str into a legible, safe URL containing only A-Z, a-z, 0-9 and - characters.