In this tutorial, you will learn how to display HTML in Blade with Laravel 8. I am assuming, you have basic knowledge PHP and laravel. We’ll create a sample blade template and display HTML.
Blade Templates may be used for your frontend using Laravel, a fantastic PHP framework.
The blade is a robust templating engine included with Laravel that allows users to use standard PHP code in their views.
Blade view files that use the .blade.php
file extension and are stored in the resources/views
directory.
A Laravel application is up and running, if not please create a new laravel application and run the server.
You need to create a blade template file hello.blade.php
in the resources/views
folder.
The blade template is using syntax {{}}
to access a variable which are defined in the controller method.
You can use syntax {{ $some_variable }}
to echo out the content of a specific variable in Blade.
Let’s define a hello variable in a controller method:
$hello_msg = "<h2>Hello, Good morning</h2>";
$hello_msg
collection which has H1 HTML elements in the string, if you were to use the following:
<div>{{ $hello_msg }}</div>
Output:
<h2>Hello, Good morning</h2>
If you don’t want your HTML tags to be escaped then you should use {!! !!}
just like this:
Output:
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More
View Comments
Very usefull. Thanks.