Reputation: 45
I am using Laravel 4.2 and am attempting to pull a string from the a database column named $meta_title and save that string as the meta tag in the view. It should work like this:
$meta_title = 'Star Wars is Better than Star Trek';
$meta_title
is pulled from the database in the controller and sent to the view via an array
<meta property="og:title" content= {{ $meta_title }} {{ '>' }}
<meta property="og:title" content="Star Wars is Better than Star Trek">
but instead it does this:
<meta property="og:title" content="Star" wars="" is="" better="" than="" star="" trek="">
How can I fix the code so that the the meta tag looks like this:
<meta property="og:title" content="Star Wars is Better than Star Trek">
after the string is pulled from the database?
Upvotes: 3
Views: 986
Reputation: 5958
You need to put {{ $meta_title }}
inside double quote
<meta property="og:title" content="{{ $meta_title }}">
From your code, after it renders to html it will look like this
<meta property="og:title" content= Star Wars is Better than Star Trek >
That is why you got a weird output.
Upvotes: 5
Reputation: 1537
What happens when you do this?
<meta property="og:title" content= "{{ $meta_title }}" >
Upvotes: 2