In a blade template, you see #section, #content, #yield etc. What are blade directives? Are they comparable to PHP or HTML? There doesn't seem to be much explanation on Laravel syntax in the framework.
At a basic level Blade is a templating language that compiles down to PHP and HTML.
When you use #section, #content or #yield in a .blade template file it will be compiled down to PHP.
If you want to dive in exactly to how it works try looking through the tests in frameworks Github or taking a look at the API.
Related
If I have a basic component with inline scripts like this
LARAVEL PHP COMPONENT
#if(true)
<div class="button-comp"></button>
#endif
<script>
#if(true)
document.querySelector('.button-comp').addEventListener('click', (e) => console.log(e) );
#endif
</script>
the Blade if directives inside the script tags, will not highlight in a correct way:
is there any settings that I'm missing in my vscodes's laravel extensions?
Laravel Extra Intellisense
Laravel Blade Snippets
UPDATE
this is related to LARAVEL BLADE SNIPPETS extension, there are other users with the same issue https://github.com/onecentlin/laravel-blade-snippets-vscode/issues/127. As #TimLewis wrotes in the comments, only solution is to assign the PHP variable to a JS variable, and use a JS if statement,in this way I can avoid the use of blade directives.
Laravel how can I use the require file when using #section('content') method, how can I require the file into the this?
I want to using the menu bar, but I don't know how to separate it.
I have this code
<div class="links">
About Me
Employment History
News
Blog
Nova
Forge
Vapor
GitHub
</div>
can independent to menu.php
Make menu.blade.php with this code in your views directory.
In place of code write #include('menu')
If location of file is different then #include('path-to-file') will be loaded.
In Laravel blade you can use #include('file path')
You can use yield() to solve the problem.
Is there a way to make life harder on users which trying to copy my html source in laravel blade templates?
Is it possible to obfuscate blade template without javascript? I know about this for example {{ HTML::obfuscate('me#gmail.com') }} it is working with emails..
My idea is to use laravel blade in the <template></template> of a vue/vueify component. I am not sure how to get the blade processor to run and output the html into the template inside the .vue file or in an imported template file.
I don't believe what he's trying to do is preposterous.
I find that there're things that Laravel blade does better than Vue and just want to get a prepared blade run template to be returned asynchronously using vue resource.
What you can do is actually make vue blade templates. That are actually then passed by Laravel via a route that returns a view that has vue code. That way it enables the user of blade templates to do what he does best in PHP and blade them return a good vue template that had code.
If you have the template inline then you can output whatever you want inside of it ( from your something.blade.php file ):
<super-duper-component inline-template >
{!! $some_php_variable_sent_to_the_view !!}
#{{ $data.someVueDataProperty | json }}
</super-duper-component>
You can use the blade #include('path-to.super-duper-component') to include this snippet from a simple super-duper-component.blade.php file so you can keep the component's template in one location for maintaining the template in the future.
TL;DR: What is the correct way to link to a stylesheet in Laravel 5?
Background:
I'm using the dev version of Laravel 4.3 (5) because I want to use Socialite, and it makes sense to develop with that from the start. I am having a problem getting templates transferred from 4.2
I've moved my blade layout files to the new directory structure (resources/templates) and placed my CSS in the public/css/ folder.
When I load my route /test/ all I get is "Whoops, looks like something went wrong."
For testing purposes I've removed all blade layout syntax from my layouts - the raw HTML works, but there is no styling (as there is no linked stylesheet). That tells me the routes, views and controllers work.
The problem:
In my layouts, if I remove the following, the layouts work:
{{ HTML::style('css/bootstrap.min.css') }}
{{ HTML::style('css/style.css') }}
Question:
What is the correct location and syntax for Blade Stylesheet inclusion in Laravel 5 and what I should be using instead?
The HtmlBuilder has been removed from Laravel's core, so HTML::style() is no longer available.
If you want to use it in laravel 5, add the following to your composer.json file, under the require key:
"laravelcollective/html": "~5.0"
Also note, since HTML::style() returns HTML code, you don't want it escaped. Use the raw brackets:
{!! HTML::style('css/style.css') !!}
Adding to #joseph's answer, for the users preferring not to switch to the new syntax, you can use
Blade::setRawTags('{{', '}}');
and continue with the old syntax . this can be set almost anywhere, but a better choice would be a service provider, say legacy service provide for l4 . you can find further discussion on this at laracasts, where you can find taylor otwells thoughts on this .
If you want to use plain HTML then use like this-
<link rel="stylesheet" href="/css/folder/style.css">