我沒有看到任何人100%的去耦HTML/CSS,但你可以遵循一些設計模式,如演示,並使用Laravel刀片所以它是非常小的耦合。
名的視圖中home.blade.php
,並添加您的代碼,並改變你的代碼:
<?php
Route::get('/', function() {
return View::make('home',
array(
'$pageTitle' => 'Dashboard',
'welcomeMessage' => 'Welcome to your Dashboard. You rock!'
)
);
});
請參見:
<h1>{{$pageTitle}}</h1>
<p>{{$welcomeMessage}}</p>
<div class="bubbletree-wrapper">
<div class="bubbletree"></div>
</div>
使用創建路線?這幾乎是100%的解耦,但你不能脫鉤100%,否則你會無法顯示在您的最終HTML的動態數據。
此外,刀片可以幫助你組織你的代碼,這樣你就可以有一個佈局,讓我們把它layout.blade.php
:
你必須在它葉片的一個單行,只是爲了增加你的頁面內容,現在你可以創建你的家查看:
@extends('layout')
@section('contentSection')
<h1>{{$pageTitle}}</h1>
<p>{{$welcomeMessage}}</p>
<div class="bubbletree-wrapper">
<div class="bubbletree"></div>
</div>
@stop
和刀片將呈現此HTML你:
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title> Your Application </title>
<link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap.min.css">
</head>
<body class="">
<h1>Dashboard</h1>
<p>Welcome to your Dashboard. You rock!</p>
<div class="bubbletree-wrapper">
<div class="bubbletree"></div>
</div>
</body>
</html>
爲什麼? '.blade.php'就在這裏。它是模板文件。它應該保存HTML代碼。你的問題就像「我想開車去上班,但我不想坐汽車旅行」 – Andreyco