Open Aristona opened 11 years ago
Agreed. I'll add this in.
View::composer(array('*view_post'), function($view)
{
$viewdata=$view->getData();
if(!Auth::check()) return $view->nest('commentForm', 'site/blog/comment_auth');
if(!$viewdata['canComment']) return $view->nest('commentForm', 'site/blog/comment_perm');
return $view->nest('commentForm', 'site/blog/comment_form', array('post' => $viewdata['post']));
});
Then split out the html to seperate files, comment_auth, _perm and _form and replace them with {{ $commentForm }} in view_post
Hi,
I just downloaded the starter kid and came across this:
Excuse me - but this is crazy. Incredible amount of unnecessary work in our views, which is also unmaintainable.
Correct way should be:
Now, you can bind the comment form whereever you want only by adding view name into the composer array.
What benefits do you get?