<?php
/**
 * A class for rendering textile templates.
 */
class view_widget_textile
{
    /**
     * @var Textile The textile object.
     */
    protected static $textile;

    ////////////////////////////////////////////////////////////////////////////
    // Construct and destruct functions.

    ////////////////////////////////////////////////////////////////////////////
    // Overload functions.

    ////////////////////////////////////////////////////////////////////////////
    // Interface functions.

    /**
     * Renders an html template.
     * 
     * @param string $template The textile template.
     * @param boolean $restricted Whether to render in restrict mode or not.
     * @return string The rendered template.
     */
    public static function render($template, $restricted = true)
    {
        if (!self::$textile)
        {
            self::$textile = new Textile;
        }
        
        return self::$textile->{'Textile' . (($restricted) ? 'Restricted' : 'This')}($template);
    }

    ////////////////////////////////////////////////////////////////////////////
    // Internal functions.
}
