Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a Laravel 5.1 project that I'm trying to improve and now migrating some features to Vue.js to make it more interactive and stuff.

In my view I have

<img src="{{ file_storage_path($product->path) }}" alt="{{$product->name}}"/>

This is default implementation using Laravel's blade.

Now, when I delegate this to the Vue.js I would have something like this

<img src="{{ file_storage_path(product.path) }}" alt="@{{product.name}}"/>

But this of course fails. So I need both - to invoke a php-function and at the same time to render Vue data.

I tried this

src="{{ file_storage_path( @{{product.path}} ) }}"

But of course this fails too. any suggestions?

share|improve this question
up vote 0 down vote accepted

Since I couldn't find a way to inline both blade syntax and Vue.js variable rendering I see the solution is to first invoke the php function and then append the Vue.js rendering to it.

So, the workaround would be

 <img :src="'{{ file_storage_path('/') }}' + image.path" alt="@{{product.name}}" />

This solution would work only for specific case, it doesn't get answer to my original question, when a php function actually needs to accept a Vue variable. But in this case, I can simply append values.

share|improve this answer
1  
Please edit and explain your answer – Rohit Gupta Nov 7 '15 at 19:53
    
@RohitGupta there is nothing actually edit or explain. I found a working solution and posted it as someone might be facing same problem – AndrewMalinnkov Nov 7 '15 at 19:56
    
As it stands the answer is pending deletion as being low quality. The way you improve it is to explain it. Are you saying, you do not understand your own answer ? – Rohit Gupta Nov 7 '15 at 19:58
    
@AndrewMalinnkov Really, code-only answer isn't a good answer. Explain what are you doing, why are you doing this is a good idea. – Kevin Guan Nov 8 '15 at 0:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.