在laravel中,您可以编写以下代码,以便每次加载页面时,只会加载该页面所需的样式表和JavaScript。我如何在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&subset=all" rel="styleshee " type="text/css">
@stop
@section('content')
答案 0 :(得分: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&subset=all", :rel => "stylesheet", :type => "text/css"}
- content_for :content do