Home > Jet

Print
Jet

Jet is the template engine for Jaskell.

A Jet file is just a jaskell expression file that evaluates to a string. Templating is done by using jaskell string interpolation.

Data model, servlet request, servlet response, servlet session are visible to the page as regular variables.

Because Jet file is a regular jaskell expression, functions can be defined to reuse presentation logic.

Some predefined functions are available to make authoring html easy.

The following is an example jet file:

$$<<
<html>
${tag "title" title}
<body>
  ${b title}: $br
  <table>
    <tr>
      ${sequence ["name", "price", "isbn"] th}
    </tr>
    ${sequence {p=books} $ tr[html.escape(p.name), asmoney(p.price), p.isbn]}
  </table>
</body>
</html>
>>$$
where
  asmoney n = "$" + format {pattern="##.00"} n;
end

Given a data model where title as "Book List" and books as a list of [Learning Jaskell, Jet & JSP], the result html will become:

<html>
<title>Book List</title>
<body>
  <b>Book List</b>: <br>
  <table>
    <tr>
      <th>name</th><th>price</th><th>isbn</th>
    </tr>
    <tr>
      <td>Learning Jaskell</td><td>$50.30</td><td>ASD9097BS768D9c</td>
    </tr>
    <tr>
      <td>Jet &amp; JSP</td><td>$30.00</td><td>87daCa089JCD</td>
    </tr>
  </table>
</body>
</html>

Class Jet is used to enable Jet support.

Custom Resolver can be built to make application scope, session scope, request scope variables and other data model visible to the Jet page.

Powered by Atlassian Confluence