Skip to content

Instantly share code, notes, and snippets.

@Cacodaimon
Created November 5, 2013 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cacodaimon/7321018 to your computer and use it in GitHub Desktop.
Save Cacodaimon/7321018 to your computer and use it in GitHub Desktop.
Tiny slim json view.
class SlimJsonView extends \Slim\View
{
public function render($template = null)
{
$app = \Slim\Slim::getInstance();
!$this->has('error') && $this->data->remove('flash');
!$this->has('flash') && $this->data->remove('flash');
$app->response()->header('Content-Type', 'application/json');
$app->response()->body(json_encode($this->all()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment