logo





GradeBook released!
Oct, 2008
Solstice adds a grade book to its toolkit!

New Versions!
April, 2008
A new version of all our software is available!

CommonView Released
April, 2008
Check out our latest collaborative tool.

RESTful Web Services
Jan, 2008
Solstice provides support for RESTful development.

How to work with templates

The basics

Templates in Solstice provide an easy and straightforward way to control the content of your web application. Control comments can be added to an HTML file to add dynamic content, or control what parts of a page are displayed. Here's a simple example:

<h1><!-- sol_var page_title --></h1>
This is my page, the heading has a dynamic value.

The value of page_title is set by a view object, as is mentioned in How to work with views.

Page Control

The Solstice templating engine has 2 ways to control the flow of a page, sol_if and sol_unless.

<!-- sol_if rainy -->
Better get an umbrella!
<!-- sol_else -->
Looks nice out
<!-- /sol_if -->

sol_unless works the same way:

<!-- sol_unless rainy -->
Looks nice out
<!-- sol_else -->
Better get an umbrella!
<!-- /sol_unless -->

The values used in these comparisons are just normal params. Any true value (such as 1, 'sunny', or an array ref) will result in the sol_if block being displayed.

Don't forget to close your sol_if with a /sol_if!

Loops

When you want to iterate over a set of data, you can use sol_loop. When you use addParam instead of setParam, you can use sol_loop to access each set of params you have added.

<!-- sol_loop fruits -->
Name: <!-- sol_var fruit_name -->
<!-- /sol_loop -->

When you're working with a loop, the Solstice templating engine gives you access to 4 extra variables that can help you control your layouts. They are __FIRST__, __LAST__, __EVEN__ and __ODD__. These extra variables will be true when appropriate, and false otherwise. To create a table with alternating rows, you could do the following:

<table>
 <tr>
   <th>Name</th>
   <th>Email</th>
 </tr>
 <!-- sol_loop people -->
 <!-- sol_if __EVEN__ -->
 <tr class="even_row">
 <!-- sol_else -->
 <tr class="odd_row">
 <!-- /sol_if -->
   <td><!-- sol_var name --></td>
   <td><!-- sol_var email --></td>
 </tr>
 <!-- /sol_loop -->
 </table>

You should now be ready to start creating templates of your own!