[work on menus showing if item is selected thomashartman1@gmail.com**20080813163634] hunk ./src/Controller.hs 16 +import Debug.Trace hunk ./src/Controller.hs 22 -controller = debugFilter $ - tutorial ++ loginHandlers ++ simpleHandlers ++ usingTemplatesHandlers ++ staticfiles +controller = {- debugFilter $ -} + tutorial ++ loginHandlers ++ simpleHandlers ++ usingTemplatesHandlers ++ staticfiles hunk ./src/Controller.hs 47 - [tmpl] -> ( ioMsgToWeb . withBaseTemplateW [] ) tmpl + [tmpl] -> do + ( ioMsgToWeb . withBaseTemplateW [] ) (trace ("\n\ntmpl: " ++ tmpl ++ "\n\n") tmpl) hunk ./src/Controller.hs 51 +-- menuAttrs <- return $ getMenuAttrs tmpl + +getMenuAttrs tmpl = [("homeSelected",""), + ("loginSelected"," is selected "), + ("loggedInAsSelected",""), + ("viewAllUsersSelected","")] + + hunk ./src/ControllerBasic.hs 36 -simpleHandlers = debugFilter [ +simpleHandlers = [ hunk ./src/ControllerUsingTemplates.hs 13 -usingTemplatesHandlers = debugFilter [ +usingTemplatesHandlers = [ hunk ./src/Misc.hs 52 -traceMsg msg x = trace ( msg ++ (show x) ) x +traceMsg msg x = trace ( "\n\n" ++ msg ++ (show x) ++ "\n\n") x hunk ./src/View.hs 13 - withBaseContentW content + menuAttrs <- return $ getMenuAttrs contentTmpl + -- withBaseContentW content + renderTut ( [("contentarea",content)] ++ menuAttrs) "base" + +getMenuAttrs tmpl = [("homeSelected",""), + ("loginSelected"," is selected "), + ("loggedInAsSelected",""), + ("viewAllUsersSelected","")] + hunk ./src/View.hs 28 -renderTut attrs tmpl = withTutTemplate ( renderDef attrs tmpl ) +renderTut attrs tmpl = withTutTemplate ( renderDef (traceMsg "attrs in View.hs" attrs) tmpl ) hunk ./templates/base.st 12 + login selected: $ loginSelected $ hunk ./templates/header.st 6 -
Every page in this tutorial has certain things in common -- the header and menu bar for example. +You wouldn't want to have have to change the menu bar on every single page if there was a new menu item. + +
This is why you need a templating system.
+ +A templating system also helps you individualize output. +For instance, you might want the menu bar to display what user is currently logged in. +(I haven't gotten this working yet, but I will.) +So a templating system also gives you a way to insert variable text into placeholder templates. +
+ +HAppS doesn't care much what templating system you use. +I use the TK HStringTemplate package to get the job done.
+ +Follow the links below by clicking on them. +Each "page" link is paired with one or more "code" or "template" links that you should also follow. +Try to match what is happening in the page link with what went on behind the scenes in the code and template links.
+ +