Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Added Zepto\Router::generate_error_template() to create generic H…
Browse files Browse the repository at this point in the history
…TML templates for error pages
  • Loading branch information
hassankhan committed Jan 30, 2014
1 parent 5223de1 commit fb45afb
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions library/Zepto/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,15 @@ public function not_found($callback = null)
}
}


protected function default_not_found_handler()
{
// Use Twig to do something nice
// Generate a response
return "Didn't find anything";
return $this->generate_error_template("Page Not Found", "Couldn't find your, like, page, dude");
}

protected function default_error_handler($error = '')
protected function default_error_handler($error = "Something fucked up big time")
{
return 'Server error: ' . $error;
return $this->generate_error_template("Server Error", $error);
}

/**
Expand Down Expand Up @@ -393,4 +392,16 @@ protected function parse_parameters(Route $route)
return $params;
}

/**
* Returns a standard template for error messages. Thanks, Slim
*
* @param string $title
* @param string $body
* @return string
*/
protected function generate_error_template($title, $body)
{
return sprintf('<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body><h1>%s</h1><p>%s</p></body></html>', $title, $title, $body);
}

}

0 comments on commit fb45afb

Please sign in to comment.