module Panda.Type.StaticWidget where

import Panda.Helper.Env hiding (body)
import Prelude hiding ((.), (/), (^), id, readFile)
import Panda.Type.Reader

data StaticWidget = StaticWidget
  { name :: String
  , body :: String
  , reader :: Reader
  }
  deriving (Show, Eq)

instance Markable StaticWidget where
  markup x  = render_to_html (x.reader) (x.body)

read_static_widget default_reader s = liftM2 (StaticWidget name) body (return reader) where
  body = s.to_utf8.readFile
  reader = s.take_extension.guess_reader.fromMaybe default_reader
  name = s.takeFileName.dropExtension