lib/Timber.php
public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT, $via_render = false ) {
		if ( !defined('TIMBER_LOADED') ) {
			self::init();
		}
		$caller = LocationManager::get_calling_script_dir(1);
		$loader = new Loader($caller);
		$file = $loader->choose_template($filenames);

		$caller_file = LocationManager::get_calling_script_file(1);
		apply_filters('timber/calling_php_file', $caller_file);

		if ( $via_render ) {
			$file = apply_filters('timber_render_file', $file);
		} else {
			$file = apply_filters('timber_compile_file', $file);
		}

		$output = false;

		if ($file !== false) {
			if ( is_null($data) ) {
				$data = array();
			}

			if ( $via_render ) {
				$data = apply_filters('timber_render_data', $data);
			} else {
				$data = apply_filters('timber_compile_data', $data);
			}

			$output = $loader->render($file, $data, $expires, $cache_mode);
		}

		do_action('timber_compile_done');
		return $output;
	}
public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = Loader::CACHE_USE_DEFAULT, $via_render = false ) {
		if ( !defined('TIMBER_LOADED') ) {
			self::init();
		}
		$caller = LocationManager::get_calling_script_dir(1);
		$loader = new Loader($caller);
		$file = $loader->choose_template($filenames);

		$caller_file = LocationManager::get_calling_script_file(1);
		apply_filters('timber/calling_php_file', $caller_file);

		if ( $via_render ) {
			$file = apply_filters('timber_render_file', $file);
		} else {
			$file = apply_filters('timber_compile_file', $file);
		}

		$output = false;

		if ($file !== false) {
			if ( is_null($data) ) {
				$data = array();
			}

			if ( $via_render ) {
				$data = apply_filters('timber_render_data', $data);
			} else {
				$data = apply_filters('timber_compile_data', $data);
			}

			$output = $loader->render($file, $data, $expires, $cache_mode);
		}

		do_action('timber_compile_done');
		return $output;
	}
public static function compile ( $ filenames , $ data = array ( ) , $ expires = false , $ cache_mode = Loader :: CACHE_USE_DEFAULT , $ via_render = false ) { if ( ! defined ( 'TIMBER_LOADED' ) ) { self :: init ( ) ; } $ caller = LocationManager :: get_calling_script_dir ( 1 ) ; $ loader = new Loader ( $ caller ) ; $ file = $ loader -> choose_template ( $ filenames ) ; $ caller_file = LocationManager :: get_calling_script_file ( 1 ) ; apply_filters ( 'timber/calling_php_file' , $ caller_file ) ; if ( $ via_render ) { $ file = apply_filters ( 'timber_render_file' , $ file ) ; } else { $ file = apply_filters ( 'timber_compile_file' , $ file ) ; } $ output = false ; if ( $ file !== false ) { if ( is_null ( $ data ) ) { $ data = array ( ) ; } if ( $ via_render ) { $ data = apply_filters ( 'timber_render_data' , $ data ) ; } else { $ data = apply_filters ( 'timber_compile_data' , $ data ) ; } $ output = $ loader -> render ( $ file , $ data , $ expires , $ cache_mode ) ; } do_action ( 'timber_compile_done' ) ; return $ output ; }
Compile a Twig file.

Passes data to a Twig file and returns the output.

@api
@example
```php
$data = array(
'firstname' => 'Jane',
'lastname' => 'Doe',
'email' => 'jane.doe@example.org',
);

$team_member = Timber::compile( 'team-member.twig', $data );
```
@param array|string $filenames  Name of the Twig file to render. If this is an array of files, Timber will
render the first file that exists.
@param array        $data       Optional. An array of data to use in Twig template.
@param bool|int     $expires    Optional. In seconds. Use false to disable cache altogether. When passed an
array, the first value is used for non-logged in visitors, the second for users.
Default false.
@param string       $cache_mode Optional. Any of the cache mode constants defined in TimberLoader.
@param bool         $via_render Optional. Whether to apply optional render or compile filters. Default false.
@return bool|string The returned output.
Compile a Twig file .