{-# LANGUAGE OverloadedStrings #-}
module Text.Enhask.Core where

import Text.Enhask.Types

id_, class_ :: AttrValue -> AttrSelector
id_ = ("id" .=)
class_ = ("class" ~=)

purchase :: String -> Template String
purchase name =
  Template "main.html"
  (any_ [id_ "basket"] :~ tag "ul" [class_ "items"] :> firstChild "li")
  $ update (any_ [class_ "name"]) (setContent . Raw $ name)

basket :: [String] -> Template String
basket names =
  Template "main.html"
  (any_ [id_ "basket"])
  $ update (any_ [class_ "items"])
  $ mconcat $ map (appendChild . FromTemplate . purchase) names
