-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.hh
105 lines (91 loc) · 2.46 KB
/
View.hh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?hh // strict
/**
* @copyright 2010-2015, The Titon Project
* @license http://opensource.org/licenses/bsd-license.php
* @link http://titon.io
*/
namespace Titon\View;
use Titon\Cache\Storage;
/**
* The View class acts as the hub between the individual templates and the rendering engine.
* It manages a list of lookup paths, which it uses to locate templates for rendering.
*
* @package Titon\View
*/
interface View {
/**
* Return a helper by key.
*
* @param string $key
* @return \Titon\View\Helper
*/
public function getHelper(string $key): Helper;
/**
* Return all helpers.
*
* @return \Titon\View\HelperMap
*/
public function getHelpers(): HelperMap;
/**
* Return the template locator instance.
*
* @return \Titon\View\Locator
*/
public function getLocator(): Locator;
/**
* Return a variable by key.
*
* @param string $key
* @return mixed
*/
public function getVariable(string $key): mixed;
/**
* Return all variables.
*
* @return \Titon\View\DataMap
*/
public function getVariables(): DataMap;
/**
* The all-in-one rendering method that pieces together the layout, wrapper, and template,
* and returns a single rendered response.
*
* If `$private` is true, render a template from the private folder.
*
* @param string $template
* @param bool $private
* @return string
*/
public function render(string $template, bool $private = false): string;
/**
* Render a single template from the defined file system path.
* Can optionally pass in a list of variables that is accessible in the template.
*
* @param string $path
* @param \Titon\View\DataMap $variables
* @return string
*/
public function renderTemplate(string $path, DataMap $variables = Map {}): string;
/**
* Set a view helper.
*
* @param string $key
* @param \Titon\View\Helper $helper
* @return $this
*/
public function setHelper(string $key, Helper $helper): this;
/**
* Set a view variable.
*
* @param string $key
* @param mixed $value
* @return $this
*/
public function setVariable(string $key, mixed $value): this;
/**
* Set multiple view variables.
*
* @param \Titon\View\DataMap $data
* @return $this
*/
public function setVariables(DataMap $data): this;
}