I am attempting to setup a basic page using Laravel and twitter bootstrap. I installed Laravel and got the generic "you're here" or w/e image so that seems shiny. For twitter bootstrap, I added in my /public folder the twitter bootstrap files under /resources/js, /resources/css, and /resources/img.
So now I'm trying to make a template for my views, where basically the twitter bootstrap .css files are output in my head tag and the bootstrap.min.js and jquery.js script includes are output just before my closing body tag.
So this is what I have setup:
laravel/app/routes.php
Route::get('/', function()
{
return View::make('hello');
});
laravel/app/views/hello.php
@extends('layouts.master')
@section('content')
<p>This is my body content.</p>
@stop
laravel/app/views/layouts/master.blade.php
<html>
<head>
@section('head')
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
@show
</head>
<body>
<div class="container">
@yield('content')
</div>
@section('footer_scripts')
<script src="http://code.jquery.com/jquery.js"></script>
<script src="/resources/js/bootstrap.min.js"></script>
@show
</body>
</html>
But it the blade template doesn't seem to be rendering. This is the output I get:
@extends('layouts.master') @section('content')
This is my body content.
@stop
That's how it looks on-page as well as in the view-source. No html tag or script includes; nothing. I must be missing something basic, and I've tried looking through the Laravel docs, but I can't seem to figure out what I'm doing wrong.. can someone point me in the right direction?
Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates.
You could download the class and start using it, or you could install via composer. It's 100% compatible without the Laravel's own features (extensions).
Laravel Blade template engine enables the developer to produce HTML based sleek designs and themes. All views in Laravel are usually built in the blade template. Blade engine is fast in rendering views because it caches the view until they are modified. All the files in resources/views have the extension .
The blade templates are stored in the /resources/view directory. The main advantage of using the blade template is that we can create the master template, which can be extended by other files.
To use a blade template you must have the .blade
in file name, for example in your case it should be
hello.blade.php
Otherwise, it won't render. Read more on Laravel Site.
Here is an example from one of my testing projects (index.blade.php), since you had a typo @extends('layout.master')
it should be something like this
@extends('layouts.master')
@section('content')
This is a sample of laravel 4 using blade template engine.
This is home page using HomeController and home.blade template.
@stop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With