aboutsummaryrefslogtreecommitdiff
path: root/vendor/flexi/examples/04_handler_plugin/mustache.php
blob: 604c99436a26a4bd95f397cb94a16b5e945b5e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
error_reporting(E_ALL ^ E_NOTICE);

// load flexi lib
require_once dirname(__FILE__) . '/../../lib/flexi.php';

// where are the templates
$path_to_the_templates = dirname(__FILE__) . '/templates';

// we need a template factory
$factory = new Flexi_TemplateFactory($path_to_the_templates);

// load haml plugin

require_once dirname(__FILE__) . '/../../lib/mustache_template.php';
$factory->add_handler('mustache', 'Flexi_MustacheTemplate');

// open template
$template = $factory->open('mustache');

$template->set_attributes(array(
  "name" => "Chris",
  "value" => 10000,
  "taxed_value" => 10000 - (10000 * 0.4),
  "in_ca" => true
));

// test mix of different template engines
$template->set_layout("layout");

// render template
echo $template->render();