Skip to content

Commit

Permalink
Add json template view
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-factorin committed Jul 23, 2018
1 parent 050bdae commit 7f64e76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/JsonView.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Slimcake\Templates;

/**
* Class JsonView
* @package Slimcake\Templates
*/
class JsonView extends View
{
public function build()
{
header('Content-Type: application/json; charset=utf-8');
return json_encode($this->data);
}
}
2 changes: 1 addition & 1 deletion src/TemplateView.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function build()
$this->set('__contents__', parent::build());
$this->render($this->template);

return $this->build();
return $this->extract();
}

/**
Expand Down

0 comments on commit 7f64e76

Please sign in to comment.