Created
December 15, 2011 15:44
-
-
Save uppfinnarjohnny/1481559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tag { | |
public $name; | |
public $contents; | |
public function __construct($name, $contents = array()) { | |
$this->name = $name; | |
$this->contents = $contents; | |
} | |
public function has_contents() { | |
return ! empty($this->contents); | |
} | |
} | |
$view = array( | |
'tags' => array( | |
new Tag('some_tag', array()), | |
new Tag('another_tag', array('value1', 'value2')) | |
) | |
); | |
$template = <<<EOT | |
<li> | |
{{#tags}} | |
<li>{{name}}</li> | |
{{#has_contents}} | |
<ol> | |
{{#contents}} | |
<li>{{.}}</li> | |
{{/contents}} | |
</ol> | |
{{/has_contents}} | |
{{/tags}} | |
</li> | |
EOT; | |
$m = new Mustache($template, $view); | |
echo $m->render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment