Core BML

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?> 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.


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

_info directives


Specify and load a required package


Specified page is dynamic, and shouldn't be cached


Specified page is static; ok to cache


Turn off default BML headers


Specify that page has no cacheable content


Declare page specific BML blocks.


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* are a variety of escape blocks, each with a different purpose:


Replace certain ASCII characters with their HTML entity counterparts


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


Escape non-compliant ASCII characters in URLs


Escape text by passing through eh and then eb


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