Core BML
blocks

Core blocks are predefined blocks that are named with a leading underscore. Most core blocks have a higher purpose than simple template use:

_code

<?_code _code?> blocks are perhaps the most useful feature of BML outside of the ability to have global site templates. These blocks allow template authors to embed pieces of executable Perl code within the bml page that get executed on the server.

The code you write gets executed in its own package (namespace) called BMLCodeBlock::. Any variables you declare in one code block on a page without using my are carried on to the next _code block.

Because the BML parser must evaluate everything on the page before sending the HTTP headers, make sure you don't print anything. Any output printed to STDOUT will just be interpreted as HTTP headers. How the _code blocks work is that you need to return a value at the end. Whatever value your code fragment returns is what the block evaluates to. Usually what you end up doing is building a string, concatenating things to it over and over, and then returning it at the end.

_c - _comment

Comment blocks are templates that do not get parsed into resultant text later, and are useful when HTML style comments (‘<!-- -->’) are not desired.

_info

Information blocks can be used to include special information about the particular BML page the block is contained in.

_info directives

package

Specify and load a required package

nocache

Specified page is dynamic, and shouldn't be cached

static

Specified page is static; ok to cache

noheaders

Turn off default BML headers

nocontent

Specify that page has no cacheable content

localblocks

Declare page specific BML blocks.

_include

Include blocks can be used to integrate a text file straight into a BML file. Include files can be written in BML or plain text.

_e*

_e* are a variety of escape blocks, each with a different purpose:

_eh

Replace certain ASCII characters with their HTML entity counterparts

_eb

Replace certain ASCII characters that can trigger BML blocks (‘<?xml?>’) with their HTML entity counterparts

_eu

Escape non-compliant ASCII characters in URLs

_ea

Escape text by passing through eh and then eb

_ml

Multi language blocks are used to interchange certain text blocks with the specified language-domain translation.