MDL-43089 move rendering code from lib.php to renderer.php.