.. _phlyty.modules.views: Views ===== Views are the presentation layer of the application. Typically, you will use a templating engine to create the presentation, though ``Phlyty`` makes no assumptions about what or how that engine works. It only requires that you provide a class implementing ``Phlyty\View\ViewInterface`` that provides a ``render`` method; it is then up to you to pass the two arguments to that method on to your templating engine in order to obtain a representation. If the above does not suit your needs, you can, of course, always instantiate your own view objects and use them as you see fit in the application. The ViewInterface ----------------- The ``ViewInterface`` is a trivial definition: .. code-block:: php namespace Phlyty\View; interface ViewInterface { /** * Render a template, optionally passing a view model/variables * * @param string $template * @param mixed $viewModel * @return string \*/ public function render($template, $viewModel = []); } Mustache Integration -------------------- ``Phlyty`` uses `phly_mustache viewModel(); $model->route = 'bar'; $model->bindHelper('link', function () { return $this->__app()->urlFor($this->route); }); The template might look like this: .. code-block:: html You should visit