Skip to content

Instantly share code, notes, and snippets.

@riaf
Created April 22, 2009 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riaf/99666 to your computer and use it in GitHub Desktop.
Save riaf/99666 to your computer and use it in GitHub Desktop.
<?php
/**
* Ethna_Renderer_Mumu.php
*
* @author riaf <riafweb@gmail.com>
* @package Ethna
* @version $Id$
*/
require_once 'mumu.php';
/**
* Mumuレンダラクラス
*
* @author riaf <riafweb@gmail.com>
* @access public
* @package Ethna
*/
class Ethna_Renderer_Mumu extends Ethna_Renderer
{
/**
* Ethna_Renderer_Mumuクラスのコンストラクタ
*
* @access public
*/
function Ethna_Renderer_Mumu(&$controller){
parent::Ethna_Renderer($controller);
$this->template_dir = $controller->getTemplatedir();
if($this->template_dir{strlen($this->template_dir) - 1} != "/"){
$this->template_dir .= '/';
}
}
/**
* ビューを出力する
*
* @param string $template テンプレート名
* @param bool $capture true ならば出力を表示せずに返す
*
* @access public
*/
function perform($template = null, $capture = false){
if ($template === null && $this->template === null) {
return Ethna::raiseWarning('template is not defined');
}
if ($template !== null) {
$this->template = $template;
}
// テンプレートの有無のチェック
if (is_readable($this->template_dir. $this->template) === false) {
return Ethna::raiseWarning("template is not found: ". $this->template);
}
$mumu = MuParser::parse_from_file($this->template_dir. $this->template);
if ($capture === true) {
return $mumu->render($this->prop);
} else {
echo $mumu->render($this->prop);
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment