package main

import (
	"fmt"
)

// pageData is stuff that changes per request
type pageData struct {
	Site          *SiteData
	Title         string
	SubTitle      string
	Stylesheets   []string
	HeaderScripts []string
	Scripts       []string
	FlashMessage  string
	FlashClass    string
	LoggedIn      bool
	IsAdmin       bool
	Menu          []menuItem
	BottomMenu    []menuItem
	session       *pageSession

	TemplateData interface{}
}

func (p *pageData) show(tmplName string) error {
	for _, tmpl := range []string{
		"htmlheader.html",
		"header.html",
		tmplName,
		"footer.html",
		"htmlfooter.html",
	} {
		if err := outputTemplate(tmpl, p, p.session.w); err != nil {
			fmt.Printf("%s\n", err)
			return err
		}
	}
	return nil
}
