An article:
Generating a Link to a Javascript File
Problem
You want your Blade template to the load an external JavaScript file.
Instead of using <script ...> directly, you want to does this with the HTML facade.
Solution
Use the HTML::script() method.
Just Pass the path to the JavaScript file.
{{Html::script (' Js/functions.js ')}}
This produces the following HTML code.
<scriptsrc="Http://your.url/js/functions.js"></script>
If the file path you pass is ' t a complete URL, Laravel'll use your application's URL to build a complete URL.
You can pass additional attributes in an array as the second argument.
{{Html::script (' js/functions.js ', Array (' async ' = ' async ')}}}
The attributes is added to the script tag as the result below illustrates.
<scriptAsync="Async"src="Http://your.url/js/functions.js"></script >
Discussion
The type attribute of <script> tags is optional with HTML5.
But if your Web page was still HTML 4.01, you should add the ' to the ' "type" => "text/javascript" attributes you pass this method.
Transferred from: http://laravel-recipes.com/recipes/183
Written in the previous words:
1. If you need to use the Blade template engine
The 2.css JS image folder is built under the public directory of Laravel.
3. The generated path is the relative path by default
A: Load the CSS file (replace the normal link with the following format)
{{Html::style (' Css/custom.css ')}}
The resulting appearance in the page is as follows
<link media= "All" type= "text/css" rel= "stylesheet" href= "http://local.lv.com/css/ Custom.css ">
B: Load the JS file (replace the normal script with the following format)
{{Html::script (' Js/custom.js ')}}
The resulting appearance in the page is as follows
<script src= "Http://local.lv.com/js/custom.js" ></script>
C: Add images to the page (also remove the IMG tag)
{{html::image (' Images/hot_1.gif ')}}
What the build looks like
src= "Http://local.lv.com/images/c_4.gif" >
If you want to customize the IMG (add alt or title and other attributes), then nothing to change, the direct use of on it, if you need to configure Apache, Set the DocumentRoot directly to the public directory, because the relative paths are used .
Transferred from: http://www.cnblogs.com/debmzhang/p/3500429.html
Laravel Loading JavaScript libraries