-
Notifications
You must be signed in to change notification settings - Fork 4
Views
It wouldn’t be very good practice to mix up all of our logic and presentation, and that’s why Tessera supports views and layouts. They’re also both completely optional, how is Tessera supposed to know what kind of application you’ve made? Maybe all it does is echo JSON, you probably wouldn’t need any views or layouts for that.
A view is included if it exists. Both views and layouts are stored in the views directory relative to the application’s PHP file, and the name of the view is method_name.html. For example, the route ‘/foo/bar’ => ‘foo’ would have the view views/foo.html. That’s not forced though, you can change the name of the view you use. In the method, call $this->view = 'viewname'
to use views/viewname.html. If you don’t want to use a view, but the file exists, just call $this->view = null
to turn it off.