Example #1
0
 public function test_lex_parser_in_themes()
 {
     Template::parse_views(true);
     Template::set_theme('default');
     $file = FCPATH . 'themes/default/bf_parser_test.php';
     // Create a simple file
     file_put_contents($file, '<span>{{ title }}</span>');
     Template::set('title', 'Lex Is Working');
     Template::load_view('bf_parser_test', null, '', true, $output);
     $this->assertTrue(class_exists('MY_Parser'));
     $this->assertEqual($output, '<span>Lex Is Working</span>');
     // Remove the temp file
     unlink($file);
 }
Example #2
0
/**
 * A shorthand method that allows views (from the current/default themes) to be
 * included in any other view.
 *
 * This function also allows for a very simple form of mobile templates. If being
 * viewed from a mobile site, it will attempt to load a file whose name is prefixed
 * with 'mobile_'. If that file is not found it will load the regular view.
 *
 * @example Rendering a view named 'index', the mobile version would be 'mobile_index'.
 *
 * @param string $view          The name of the view to render.
 * @param array  $data          An array of data to pass to the view.
 * @param bool   $ignore_mobile If true, will not change the view name based on mobile viewing. If false, will attempt to load a file prefixed with 'mobile_'
 *
 * @return string
 */
function theme_view($view = null, $data = null, $ignore_mobile = false)
{
    if (empty($view)) {
        return '';
    }
    $output = '';
    // If allowed, try to load the mobile version of the file.
    if (!$ignore_mobile) {
        $ci =& get_instance();
        $ci->load->library('user_agent');
        if ($ci->agent->is_mobile()) {
            Template::load_view("mobile_{$view}", $data, null, true, $output);
        }
    }
    // If output is empty, either mobile is ignored or no mobile file was found.
    if (empty($output)) {
        Template::load_view($view, $data, null, true, $output);
    }
    return $output;
}
Example #3
0
function theme_view($view=null, $data=null)
{
	if (empty($view)) return '';
	
	$ci =& get_instance();
	
	$output ='';
	Template::load_view($view, $data, null, true, $output);
	return $output;
}
Example #4
0
/**
 * A shorthand method that allows views (from the current/default themes)
 * to be included in any other view.
 *
 * This function also allows for a very simple form of mobile templates. If being
 * viewed from a mobile site, it will attempt to load a file whose name is prefixed
 * with 'mobile_'. If that file is not found it will load the regular view.
 *
 * @access  public
 * @example Rendering a view named 'index', the mobile version would be 'mobile_index'.
 *
 * @param string $view          The name of the view to render.
 * @param array  $data          An array of data to pass to the view.
 * @param bool   $ignore_mobile If TRUE, will not change the view name based on mobile viewing. If FALSE, will attempt to load a file prefixed with 'mobile_'
 *
 * @return string
 */
function theme_view($view = NULL, $data = NULL, $ignore_mobile = FALSE)
{
    if (empty($view)) {
        return '';
    }
    $ci =& get_instance();
    $output = '';
    // If we're allowed, try to load the mobile version of the file.
    if (!$ignore_mobile) {
        $ci->load->library('user_agent');
        if ($ci->agent->is_mobile()) {
            Template::load_view('mobile_' . $view, $data, NULL, TRUE, $output);
        }
    }
    // If output is empty, then either no mobile file was found
    // or we weren't looking for one to begin with.
    if (empty($output)) {
        Template::load_view($view, $data, NULL, TRUE, $output);
    }
    return $output;
}