Output buffer

Runtime behavior and ownership

Output buffer

All generated templates write into a global buffer g_output_buffer.

Every generated function does this at the beginning:

cweb_output_init();

and this at the end:

return cweb_output_get();

Consequence: no nested render calls

Because the buffer is global and every template render reinitializes it, in the current state you should not call one template function from inside another template function if you still need the previous output.

Otherwise this happens:

  1. the outer template writes into the global buffer
  2. the inner template calls cweb_output_init()
  3. the previous buffer content is discarded

That is an important property of the current design. Future Version will support <component>