Skip to content

Commit

Permalink
Refactor: Change view Function
Browse files Browse the repository at this point in the history
- CI3 view default function
  • Loading branch information
uncaose committed May 23, 2018
1 parent e75ce42 commit f4a1cba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
```php
$this->load->css('any.css'); // chainning
$this->load->js('any.js'); // chainning
$this->load->view('any', []); // chainning
$this->load->view('any', [], TRUE); // non chain, return view string
$this->load->view('any', []); // CI3 default
$this->load->view('any', [], TRUE); // CI3 default, non chain
$this->load->css()->js()->view()->view()->css()->js()->view(); // usage
```

Expand Down
6 changes: 3 additions & 3 deletions application/controllers/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function index() {
'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js',
])->js([
'src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" crossorigin="anonymous"'
])->_view('welcome_head')
->_view('welcome_message')
->_view('welcome_foot');
])->view('welcome_head')
->view('welcome_message')
->view('welcome_foot');
}
}
7 changes: 1 addition & 6 deletions application/core/MY_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ public function view( $view, $vars = [], $return = FALSE, $unshift = FALSE )
array_push( $this->_views, substr($view, strpos($view, '/')===0?1:0) ); // store viewname
}

if( $return === TRUE )
{
return parent::view($view, $vars, $return);
}

return $this;
return parent::view($view, $vars, $return);
}

public function _view($view, $vars = [], $return = FALSE, $unshift = FALSE )
Expand Down

0 comments on commit f4a1cba

Please sign in to comment.