I added in layout support, as well as some fundamental AJAX support for JSS. I’ll put in a tutorial later to show exactly how it’s done, but for now a quick description of how to do layouts in JSS:
There is a layouts directory under the views directory which contains a list of all your layouts. For example, let’s say you have a layout file called main.jsp. Your layout file might look something like this, though you can do whatever you like with it:
Where you want the content to be placed (i.e. your content) put in the tag <jss:content_for_layout/>. At the top of your controller file (e.g. recipe_controller.jss), after the import statement, put in the layout declaration:
where main is the name of your layout file.
That’s all! All your views under this controller will be using this layout. If there are any views you don’t want to have a layout, just put anywhere in your view method:
If you want to use another layout just for that view, you can also set the layout to something else e.g.
So what does it do? Using a layout for a controller allows you to enforce the same look and feel or have shared data for all the views under the same controller. This extends to the rest of your web application. I’ll talk a bit more about the AJAX support in another post.