| 1 |
<?php |
| 2 |
|
| 3 |
namespace Templately\Utils; |
| 4 |
|
| 5 |
class Views extends Base { |
| 6 |
|
| 7 |
protected $dir = ''; |
| 8 |
|
| 9 |
public function __construct( $path ) { |
| 10 |
$this->dir = trailingslashit($path); |
| 11 |
} |
| 12 |
|
| 13 |
public function get( string $template, array $args = [] ) { |
| 14 |
extract( $args ); |
| 15 |
|
| 16 |
include $this->get_path( $template ); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_path( $template ): string { |
| 20 |
return $this->dir . $template . '.php'; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_header() { |
| 24 |
$this->get( 'templates/header' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_footer() { |
| 28 |
$this->get( 'templates/footer' ); |
| 29 |
} |
| 30 |
} |