Two stage processing

Imagine that you have a forum message with the following contents:

Hello there! :-)
    How are [b]you[/b] feeling today? I'm [size=20][color=red]Happy![/color][/size]
	

Now if you just call render() every and each time a user requests this message, this means that the same translation will be performed every time, regardless of the fact that most code sequences - [b], [size], etc... are rendered in the same way independantly of the user.

If you have space to spare in your database and want to increase performance, you can use the two stage processing supported by the rendering engine. In the first stage, only the commands that do not depend on any external factor are rendered. You then store this intermediate result somewhere. When a user requests the message, you render the intermediate result (in which only a few commands and unprocessed sequences remain) instead of the original message.

For example, the intermediate result of the above message would be:

Hello there! :-)
    How are <b>you</b> feeling today? I'm <span style='font-size:20pt'>
<span style='color:red'>Happy!</span></span>

	

The only sequence left unprocessed is the smiley ( :- ), because the image inserted and its help text depend on the locale of the viewing user.