2014-10-12 37 views
0

在laravel中,您可以編寫以下代碼,以便每次頁面加載時都只加載該頁面所需的樣式表和JavaScript。我如何在HAML中做到這一點?要顯示HAML中的產量和部分

<!DOCTYPE html> 
<head> 
    @yield('head') 
</head> 
<body> 
    @yield('content') 
    @endsection 
</body> 

頁:

主要佈局

@extends('layouts.frontend') 

@section('head') 
    <!-- Fonts START --> 
    <link href="http://fonts.googleapis com/css?family=Open+Sans:300,400,600,700|PT+Sans+Narrow|Source+Sans+Pro:200,300,400,600,700,900&amp;subset=all" rel="styleshee " type="text/css"> 
@stop 

@section('content') 

回答

1

app/view/layouts/application.html.haml(或其他佈局文件),以顯示

!!! 5 
%html 
    %head 
    = yield :head 
%body 
    = yield :content 

您的網頁

- content_for :head do 
    %link{:href => "http://fonts.googleapis com/css?family=Open+Sans:300,400,600,700|PT+Sans+Narrow|Source+Sans+Pro:200,300,400,600,700,900&amp;subset=all", :rel => "stylesheet", :type => "text/css"} 

- content_for :content do