User Tools

Site Tools


view

Views

The view part of the MVC pattern is managed by Templo

Templo is a template engine based on .mtt files ( “motion twin templates” )

How it works

Simply set variables in the view object from the controller :

//MainController.hx
class MainController extends sugoi.BaseController
{
  @tpl("hello.mtt")
  function doHello(name:String){
    view.name = name;
  }
}  

Create a template named “hello.mtt” which will print the variable “name” set from the controller :

<html>
  <body> Hello ::name:: ! </body>
</html>

Another example : looping on an iterable of users to display an html list :

<ul>
::foreach u users::
  <li> ::u.name:: has id ::u.id:: </li>
::end::
</ul>

Please read templo documentation for more details