// LoadTemplate reads a template from templates and renders it with data to the given io.Writer
LoadTemplate reads a template from templates and renders it with data to the given io.Writer
// LoadTemplate reads a template from templates and renders it with data to the given io . Writer
func (tr *Renderer) LoadTemplate(w http.ResponseWriter, r *http.Request, view string, data map[string]interface{}) error {
	if tr.reload {
		err := tr.init()
		if err != nil {
			return err
		}
	}
	t, ok := tr.templates[filepath.ToSlash(view)]
	if !ok {
		return fmt.Errorf("unable to find template: %s", filepath.ToSlash(view))
	}
	if data == nil {
		data = make(map[string]interface{})
	}
	session := getSession(r)
	if flashes := session.Flashes(); len(flashes) > 0 {
		data["messages"] = flashes
	}
	errSession := getErrSession(r)
	if flashes := errSession.Flashes(); len(flashes) > 0 {
		data["errors"] = flashes
	}
	_ = session.Save(r, w)
	_ = errSession.Save(r, w)
	opts, err := raceManager.LoadServerOptions()
	if err != nil {
		return err
	}
	data["server_status"] = AssettoProcess.IsRunning()
	data["server_name"] = opts.Name
	data["User"] = UserFromRequest(r)
	t.Funcs(map[string]interface{}{
		"ReadAccess":  ReadAccess(r),
		"WriteAccess": WriteAccess(r),
		"AdminAccess": AdminAccess(r),
		"LoggedIn":    LoggedIn(r),
	})
	return t.ExecuteTemplate(w, "base", data)
}
func ( tr * Renderer ) LoadTemplate ( w http . ResponseWriter , r * http . Request , view string , data map [ string ] interface { } ) error { if tr . reload { err := tr . init ( ) if err != nil { return err } } t , ok := tr . templates [ filepath . ToSlash ( view ) ] if ! ok { return fmt . Errorf ( " " , filepath . ToSlash ( view ) ) } if data == nil { data = make ( map [ string ] interface { } ) } session := getSession ( r ) if flashes := session . Flashes ( ) ; len ( flashes ) > 0 { data [ " " ] = flashes } errSession := getErrSession ( r ) if flashes := errSession . Flashes ( ) ; len ( flashes ) > 0 { data [ " " ] = flashes } _ = session . Save ( r , w ) _ = errSession . Save ( r , w ) opts , err := raceManager . LoadServerOptions ( ) if err != nil { return err } data [ " " ] = AssettoProcess . IsRunning ( ) data [ " " ] = opts . Name data [ " " ] = UserFromRequest ( r ) t . Funcs ( map [ string ] interface { } { " " : ReadAccess ( r ) , " " : WriteAccess ( r ) , " " : AdminAccess ( r ) , " " : LoggedIn ( r ) , } ) return t . ExecuteTemplate ( w , " " , data ) }
LoadTemplate reads a template from templates and renders it with data to the given io.Writer
LoadTemplate reads a template from templates and renders it with data to the given io . Writer
// reload templates on every request if enabled, so // that we don't have to constantly restart the website