fuel/core — pull request #1028 by s4wny (2012-06-16 20:12:49+00:00)
Title: Added 'set_global' to ViewModels. This allows to create much cleaner code.

### An example ###

This change allows users to do like this:

__Controller:__

return Response::forge(ViewModel::forge('template/index'));

__ViewModel:__

set_global('baseUrl', Uri::base(0));
$this->set_global('testImgLink', $this->baseUrl . 'image/' . 0 . '/'. $name); //Note: $this->baseUrl works!

//-------------------------------------------------
// The layout
//-------------------------------------------------

$this->header = View::forge('header');
$this->search = View::forge('search');
$this->imageList = View::forge('image/list');
$this->footer = View::forge('footer');
}
}

?>

__View:__

__What I do: I load every part of my template in the ViewModel. This keeps the controllers and the views clean from irrelevant code. Hope you understand and accept this pull.__

Without this change I need too load everything in either the Controller or the View, that just feels... wrong.

Btw, I think it may would be a good idea to add every function from `classes\view.php` to `classess\viewModel.php`.