Ejemplo n.º 1
0
 /**
  * Render Haml. Append globals variables
  *
  * Simple way to use Haml
  * <code>
  * echo HamlParser::haml('%strong Hello, World!'); // <strong>Hello, World!</strong>
  * $foo = 'bar'; // This is global variable
  * echo Haml::haml('%strong= "Foo is $foo"'); // <strong>Foo is bar</strong>
  * </code>
  *
  * @param string Haml source
  * @return string xHTML
  */
 public static function haml($sSource)
 {
     static $__haml_parser;
     if (!$__haml_parser) {
         $__haml_parser = new HamlParser();
     }
     $__haml_parser->setSource($sSource);
     $__haml_parser->append($GLOBALS);
     return $__haml_parser->fetch();
 }
Ejemplo n.º 2
0
/**
 * This is the simpliest way to use
 * Haml templates. Global variables
 * are automatically assigned to
 * template.
 * 
 * @param string Haml parser filename
 * @param array Associative array of additional variables
 * @param string Temporary directory (default is directory of Haml templates)
 * @param boolean Register get, post, session, server and cookie variables
 */
function display_haml($sFilename, $aVariables = array(), $sTmp = true, $bGPSSC = false)
{
    global $__oHaml;
    $sPath = realpath($sFilename);
    if (!is_object($__oHaml)) {
        $__oHaml = new HamlParser(dirname($sPath), $sTmp);
    }
    $__oHaml->append($GLOBALS);
    if ($bGPSSC) {
        $__oHaml->append($_GET);
        $__oHaml->append($_POST);
        $__oHaml->append($_SESSION);
        $__oHaml->append($_SERVER);
        $__oHaml->append($_COOKIE);
    }
    $__oHaml->append($aVariables);
    $__oHaml->display($sFilename);
}
Ejemplo n.º 3
0
function render_partial($template, $data)
{
    $haml = new HamlParser('./templates', SITE_ROOT . '/tmp/haml');
    $haml->append($data);
    return $haml->setFile($template);
}