Skip to content

Commit

Permalink
refactoring view compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 26, 2011
1 parent 516f310 commit d9201be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion laravel/config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{
require_once SYS_PATH.'view'.EXT;

return new View_Factory($c->resolve('laravel.composer'), VIEW_PATH);
return new View_Factory($c->resolve('laravel.composer'), VIEW_PATH, STORAGE_PATH.'views/');
}),


Expand Down
13 changes: 11 additions & 2 deletions laravel/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class View_Factory {
*/
public $path;

/**
* The path to the application storage directory.
*
* @var string
*/
public $compiled;

/**
* The view composer instance.
*
Expand All @@ -21,12 +28,14 @@ class View_Factory {
*
* @param View_Composer $composer
* @param string $path
* @param string $compiled
* @return void
*/
public function __construct(View_Composer $composer, $path)
public function __construct(View_Composer $composer, $path, $compiled)
{
$this->path = $path;
$this->composer = $composer;
$this->compiled = $compiled;
}

/**
Expand Down Expand Up @@ -279,7 +288,7 @@ protected function compile()
// For simplicity, compiled views are stored in a single directory by the MD5 hash of
// their name. This allows us to avoid recreating the entire view directory structure
// within the compiled views directory.
$compiled = $this->factory->path.'compiled/'.md5($this->view);
$compiled = $this->factory->compiled.md5($this->view);

// The view will only be re-compiled if the view has been modified since the last compiled
// version of the view was created or no compiled view exists. Otherwise, the path will
Expand Down
Empty file added storage/views/.gitignore
Empty file.

0 comments on commit d9201be

Please sign in to comment.