Search code examples
laravelpathincludeslash

include path in Laravel


I want to include a path into my master.blade.php.

<script type="text/javascript">var plugin_path = '{{ asset('assets/plugins/') }}';</script>

The problem is that the path is not recognized correctly. how should I specify the path that the slash is accepted? between plugin and the following word is missing the slash


Solution

  • When you look at your console errors, you can see that it fails for resources

    /assets/pluginsboots...js/ (note missing /)

    when it should have been

    /assets/plugins/boots...js/

    asset() trims / from the beginning and the end.

    You have to write your var plugin_path a bit different

    <script type="text/javascript">var plugin_path = '{{ asset('assets/plugins') }}/';</script>