문제

I have a basic install of Laravel 4.

I have set up layouts and templating using blade 4.

I have a logo and a css file in my assets directory.

/public/assets/img/logo.png
/public/assets/css/style.css

My layout is located:

/app/views/layouts/master.blade.php

What is the correct way to include these?

I have tried this for the logo for example:

But returns nothing. It also seems like laravel 4 and blade would have a more 'proper' way of doing it.

도움이 되었습니까?

해결책

you need to use the HTML helper class.

for your CSS to appear in your <head> as a stylesheet link use:

{{ HTML::style('assets/css/style.css') }}

for your images use:

{{ HTML::image('assets/img/logo.png') }}

There are also HTMLBuilder methods for .js files and other things which are HTML-related. Note that the URLs are relative to /public in your Laravel install.

For more information, you can consult the API docs at:

http://laravel.com/api/4.1/ I can't seem to link directly to a class, so navigate on the left to Illuminate\Html\HtmlBuilder

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top