Example #1
0
	function render_partial($_view, $_data = array(), $_extra_vars = array())
	{
		// for numerically indexed data arrays, for later
		//if (is_array($_data) && $_data && is_numeric(reset(array_keys($_data))))
		//	$_data = array($_view => $_data);
		
		$_path = View::match_path($_view);
		
		$compiled = TEMP_DIR . '/' . md5($_path).'.php';
		$_data['expires'] = date("m-d-y h:i:s", strtotime("Tomorrow midnight"));
		$_data['last_modified'] = date("m-d-y h:i:s", @filemtime ($compiled));
		$_data = array_merge($_data, $_extra_vars);
		extract($_data, EXTR_REFS);
		
		// see if a compiled php copy exists for this partial
		View::Compile($_path, $compiled, serialize($_data));
		
		ob_start();
		if (is_file($compiled))
			require $compiled;
		$content = ob_get_clean();
		//unlink (str_replace(".php","_tmp.php", $compiled));
		return $content;
	}