My idea is to use laravel blade in the <template></template> of a vue/vueify component. I am not sure how to get the blade processor to run and output the html into the template inside the .vue file or in an imported template file.
-
1That's a horrible idea. IDE will be mad. Compiler will be mad. And I really see no point in doing so. Why not just use .vue files for the sake of it?Yauheni Prakopchyk– Yauheni Prakopchyk2015-12-16 14:31:03 +00:00Commented Dec 16, 2015 at 14:31
-
Yeah I had not even tried it, I was stuck in the conceptual part.jjohnson– jjohnson2015-12-17 14:47:53 +00:00Commented Dec 17, 2015 at 14:47
-
1You're stuck because this shouldn't be done.ceejayoz– ceejayoz2016-05-11 16:28:13 +00:00Commented May 11, 2016 at 16:28
2 Answers
I don't believe what he's trying to do is preposterous.
I find that there're things that Laravel blade does better than Vue and just want to get a prepared blade run template to be returned asynchronously using vue resource.
What you can do is actually make vue blade templates. That are actually then passed by Laravel via a route that returns a view that has vue code. That way it enables the user of blade templates to do what he does best in PHP and blade them return a good vue template that had code.
Comments
If you have the template inline then you can output whatever you want inside of it ( from your something.blade.php file ):
<super-duper-component inline-template >
{!! $some_php_variable_sent_to_the_view !!}
@{{ $data.someVueDataProperty | json }}
</super-duper-component>
You can use the blade @include('path-to.super-duper-component') to include this snippet from a simple super-duper-component.blade.php file so you can keep the component's template in one location for maintaining the template in the future.