PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/internetmoney.kerihosting.com/wp-content/themes/jnews/class/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : /home/trave494/internetmoney.kerihosting.com/wp-content/themes/jnews/class/Template.php

<?php
/**
 * Template
 *
 * @author      Jegtheme
 * @license     https://opensource.org/licenses/MIT
 */

namespace JNews;

/**
 * Base class for any templating that used on the themes
 *
 * @author jegbagus
 */
class Template {
	private $vars = array();
	private $templateDir;
	private $templatePostfix;

	public function __construct( $directory = 'view/', $postfix = '.php' ) {
		$this->templateDir     = $directory;
		$this->templatePostfix = $postfix;
	}

	public function __get( $name ) {
		return $this->vars[ $name ];
	}

	public function __set( $name, $value ) {
		$this->vars[ $name ] = $value;
	}

	public function assign_array( $arr ) {
		foreach ( $arr as $key => $value ) {
			$this->vars[ $key ] = $value;
		}
	}

	public function clear_prev_data() {
		if ( ! empty( $this->vars ) ) {
			foreach ( $this->vars as $key => $val ) {
				$this->$key = null;
			}
		}
	}

	public function render( $templateName, $var = array(), $output = false ) {
		$this->clear_prev_data();

		if ( ! empty( $var ) ) {
			if ( is_array( $var ) ) {
				$this->assign_array( $var );
			}
		}

		extract( $this->vars );
		if ( ! $output ) {
			ob_start();
		}
		include $this->templateDir . $templateName . $this->templatePostfix;
		if ( ! $output ) {
			return ob_get_clean();
		}
	}
}