如何从CodeIgniter中的视图替换制表符和新行?

I'm using CI for developing websites. In general we write our HTML code like bellow:

<header>
  <div class="banner">
    <div class="container">
      <div class="row">
        <div class="col-xs-12">
          <h1>Site Title</h1>
          <h2>Sub Totle</h2>
          <div class="logo"></div>
        </div>
      </div>
    </div>
  </div>
</header>

After that we load the view using CI like:

$this->load->view('view');

Now my question is, how to load this view with replacing all the tab and new line from views/view.php file like bellow?

<header><div class="banner"><div class="container"><div class="row"><div class="col-xs-12 ac"><h1>Site Title</h1><h2>Sub Totle</h2><div class="logo"></div></div></div></div></div></header>

In a single word, how to uglify HTML code of a CodeIgniter view?

Thanks in advance.

</div>

Go to system/application/config/config.php and check whether hooks enabled :

$config['enable_hooks'] = TRUE;

Declare new hook in system/application/config/hooks.php :

// compress output
$hook['display_override'][] = array(
    'class' => '',
    'function' => 'compress',
    'filename' => 'compress.php',
    'filepath' => 'hooks'
    );

Add the hook in system/application/hooks/compress.php :

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

function compress()
{
    $CI =& get_instance();
    $buffer = $CI->output->get_output();

     $search = array(
        '/
/',         // replace end of line by a space
        '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
        '/[^\S ]+\</s',     // strip whitespaces before tags, except space
        '/(\s)+/s'      // shorten multiple whitespace sequences
      );

     $replace = array(
        ' ',
        '>',
        '<',
        '\\1'
      );

    $buffer = preg_replace($search, $replace, $buffer);

    $CI->output->set_output($buffer);
    $CI->output->_display();
}

/* End of file compress.php */
/* Location: ./system/application/hooks/compress.php */

Source : http://jeromejaglale.com/doc/php/codeigniter_compress_html

Or, you can easily install this hook from : https://github.com/johngerome/CodeIgniter-Minifyhtml-hooks#codeigniter-minifyhtml-hooks