-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ability to pass array data to root template #40
Comments
Hi @njoguamos You can already pass an array, withViewData is not needed.
If you'll define the props (title, description and meta) in your Index.vue the values will become available. |
aha, in that case I misunderstood your question. |
😄 Not really, I am the one who did not explain well. |
@njoguamos I noticed there is a comma after specifying the Vue Component name. The render method on the public function index() {
return Inertia::render('Contact/Index',)->withViewData([
'title' => 'Contact Us | My App',
'description' => 'Contact us with your comments, questions, and suggestions',
'meta' => 'Some other SEO meta'
]);
} To this: public function index() {
return Inertia::render('Contact/Index')->withViewData([
'title' => 'Contact Us | My App',
'description' => 'Contact us with your comments, questions, and suggestions',
'meta' => 'Some other SEO meta'
]);
} |
@georgehanson Thanks for noting that. It was a typo and have updated my comment. However, I dug deeper to Inertia and found out that public function withViewData($key, $value)
{
$this->viewData[$key] = $value;
return $this;
} Instead it should be as suggested by this PR public function withViewData($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $k => $value) {
$this->viewData[$k] = $value;
}
} else {
$this->viewData[$key] = $value;
}
return $this;
} I hope am clear 😄 |
@njoguamos that makes sense, passing an array would probably be a good feature to have. |
+1 on this...unless I'm missing a way to update the content in the tag for SEO? |
@enzonotario thanks |
It would be nice if
withViewData()
method could accept array. That way one, can pass multiple value.This throws an error
(Too few arguments to function)
Then access the variables in blade as
Or am I missing something
The text was updated successfully, but these errors were encountered: