blade

Laravel 5 - global Blade view variable available in all templates

喜你入骨 提交于 2019-11-26 06:31:10
问题 How can I in Laravel 5 make global variable which will be available in all Blade templates? 回答1: Option 1: You can use view::share() like so: <?php namespace App\Http\Controllers; use View; //You can create a BaseController: class BaseController extends Controller { public $variable1 = "I am Data"; public function __construct() { $variable2 = "I am Data 2"; View::share ( 'variable1', $this->variable1 ); View::share ( 'variable2', $variable2 ); View::share ( 'variable3', 'I am Data 3' ); View:

Laravel stylesheets and javascript don&#39;t load for non-base routes

我与影子孤独终老i 提交于 2019-11-26 05:18:22
问题 Okay--I know this is a really elementary issue, but I can\'t figure it out. This is a question regarding Laravel. Basically, I have my stylesheets embedded in my default layout view. I\'m currently just using regular css to link them, such as: <link rel=\"stylesheet\" href=\"css/app.css\" /> It works great when I am at a single level route such as /about , but stops working when I go deeper, such as /about/me . If I look at Chrome\'s developer console I see some of the following errors (only

Laravel 5: Display HTML with Blade

谁说胖子不能爱 提交于 2019-11-26 01:33:42
问题 I have a string returned to one of my views, like this: $text = \'<p><strong>Lorem</strong> ipsum dolor <img src=\"images/test.jpg\"></p>\' I\'m trying to display it with Blade: {{$text}} However, the output is a raw string instead of rendered HTML. How do I display HTML with Blade in Laravel 5? PS. PHP echo() displays the HTML correctly. 回答1: You need to use {!! $text !!} The string will auto escape when using {{ $text }} . 回答2: For laravel 5 {!!html_entity_decode($text)!!} Figured out