|
|
|
Within the BML system itself there are several "core" blocks, blocks that you do not have to define because they are built-in and always available. All of these blocks begin with an underscore (_).
Each BML core block is discussed in more detail below.
_CODE blocks are perhaps the most useful feature of BML outside of the ability to have global site templates. These blocks let you embed pieces of executable Perl code within your 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.
![]()
![]()
Return to BML Home.