Code blocks in Discourse can be entered with ``` (three backquotes) before and after the block.
For template code, you can start with ```html to get nice syntax highlight like below.
<Loop type=post count=3>
<Field title />
</Loop>
It colors tags and attributes differently, so they’re easier to read.