3

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.

3
  • 1
    That'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? Commented Dec 16, 2015 at 14:31
  • Yeah I had not even tried it, I was stuck in the conceptual part. Commented Dec 17, 2015 at 14:47
  • 1
    You're stuck because this shouldn't be done. Commented May 11, 2016 at 16:28

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

I had not thought about including the vue into the blade... I will have to try that thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.