Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Architecture Views

alsonkemp edited this page · 2 revisions

Views are templates that produce (X)HTML. You write them using:

  1. Special versions of Text.XHtml tags. See the Turbinado.View.XHtml docs.
  2. Well-formed XHTML and special tags (much as with PHP).
  3. HAML-ish code.

Views (as all of Haskell) are white space sensitive.

Turbinado.View.XHtml Tags

… coming soon…

XHtml Tags

… coming soon…

HAML Tags

… coming soon…

The ‘markup’ function

All Views must have a markup function. The system automatically looks for the markup function in Views when rendering pages.

Example

For a large example, see the Layout used by the Turbinado website. This Layout includes a helper function within the Layout file.

A simpler example which shows both embedded XHTML and HAML:

import Data.Maybe

markup= 
        <div>
          <h1>Turbinado?</h1>
          <div style="float:right">
            <img src="http://upload.wikimedia.org/wikipedia/en/thumb/0/0e/TurbinadoSugar.jpg/757px-TurbinadoSugar.jpg" width="300" />
            <% someFunction 1 %>
          </div>

          <p>Turbinado is an easy-to-use, <% anchorTag "/Home/Performance" "fricking fast" %> web 
            application framework for Haskell (and the <ahref="http://www.haskell.org/ghc">Glorious Glasgow 
            Haskell Compiler</a>).  Naturally, this website is written in Turbinado, so head over to the 
            <% anchorTag"http://github.com/alsonkemp/turbinado-website/tree/master" "Git repo" %> to 
            see how easy it is to code websites in Turbinado.</p>
        </div>

someFunction :: Int -> VHtml
someFunction i =
  %span= show i

In the example above:

  1. Standard-ish HTML markup is used.
  2. Proper whitespace indentation is used.
  3. A call is made to anchorTag to automatically format an anchor tag.
  4. A module is imported (though not used).
  5. A function is defined and it uses HAML for its markup.

trtubinado

trturbinado is a pre-processor that converts XHTML and HAML into valid Turbinado.View.XHtml tags.

Something went wrong with that request. Please try again.