summaryrefslogtreecommitdiffstats
path: root/src/ViewInterface.php
blob: 09f62332b1324b67e5a29ed8f4cb9b84d07c7821 (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
<?php

namespace Jasny;

use Psr\Http\Message\ResponseInterface;

/**
 * Interface for abstracting over template engine.
 */
interface ViewInterface
{
    /**
     * Expose a function to the view.
     *
     * @param string        $name      Function name in template
     * @param callable|null $function
     * @return $this
     * @throws \BadMethodCallException if function can't be exposed
     */
    public function expose($name, $function = null);
    
    /**
     * Render and output template
     *
     * @param ResponseInterface $response
     * @param string            $name      Template name
     * @param array             $context   Template context as associated array
     * @return ResponseInterface
     */
    public function render(ResponseInterface $response, $name, array $context = []);
}