master

laravel/framework

Last updated at: 29/12/2023 09:25

Blade.php

TLDR

The Blade.php file in the Illuminate\Support\Facades namespace contains a class called Blade which extends the Facade class. It acts as a facade for the BladeCompiler class. The class has several methods that provide functionality for compiling views using the Blade template engine.

Methods

compile

Compiles the views based on the given path. If no path is provided, it compiles all the views.

getPath

Gets the path where the views are located.

setPath

Sets the path where the views are located.

compileString

Compiles a Blade template string into PHP code.

render

Renders a Blade template with the given data.

renderComponent

Renders a Blade component with the given component object.

stripParentheses

Strips the parentheses from a Blade expression.

extend

Extends the Blade compiler with a custom compiler.

getExtensions

Gets all the custom extensions of the Blade compiler.

if

Defines a custom Blade directive with a callback.

check

Checks if a custom Blade directive exists.

component

Registers a class-based component alias.

components

Registers multiple class-based component aliases.

getClassComponentAliases

Gets the class-based component aliases.

anonymousComponentPath

Sets the path for anonymous components.

anonymousComponentNamespace

Sets the namespace for anonymous components.

componentNamespace

Sets the namespace for class-based components.

getAnonymousComponentPaths

Gets the paths for anonymous components.

getAnonymousComponentNamespaces

Gets the namespaces for anonymous components.

getClassComponentNamespaces

Gets the namespaces for class-based components.

aliasComponent

Registers an alias for a component.

include

Includes a Blade template file.

aliasInclude

Registers an alias for an included Blade template file.

directive

Registers a custom Blade directive.

getCustomDirectives

Gets all the custom Blade directives.

prepareStringsForCompilationUsing

Specifies a callback function to prepare the strings for compilation.

precompiler

Specifies a callback function to preprocess the Blade templates.

setEchoFormat

Sets the format for echoing variables.

withDoubleEncoding

Enables double encoding when echoing variables.

withoutDoubleEncoding

Disables double encoding when echoing variables.

withoutComponentTags

Disables component tags in the Blade templates.

getCompiledPath

Gets the compiled path for a given Blade template.

isExpired

Checks if the compiled version of a Blade template is expired.

newComponentHash

Generates a new component hash for a given component.

compileClassComponentOpening

Compiles the opening tag of a class-based component.

compileEndComponentClass

Compiles the closing tag of a class-based component.

sanitizeComponentAttribute

Sanitizes a component attribute value.

compileEndOnce

Compiles the closing tag of a Blade @once directive.

stringable

Registers a class as stringable for Blade templates.

compileEchos

Compiles the echo statements in a Blade template.

applyEchoHandler

Applies the echo handler to a Blade template.

Classes

There are no additional classes in this file.

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static void compile(string|null $path = null)
 * @method static string getPath()
 * @method static void setPath(string $path)
 * @method static string compileString(string $value)
 * @method static string render(string $string, array $data = [], bool $deleteCachedView = false)
 * @method static string renderComponent(\Illuminate\View\Component $component)
 * @method static string stripParentheses(string $expression)
 * @method static void extend(callable $compiler)
 * @method static array getExtensions()
 * @method static void if(string $name, callable $callback)
 * @method static bool check(string $name, mixed ...$parameters)
 * @method static void component(string $class, string|null $alias = null, string $prefix = '')
 * @method static void components(array $components, string $prefix = '')
 * @method static array getClassComponentAliases()
 * @method static void anonymousComponentPath(string $path, string|null $prefix = null)
 * @method static void anonymousComponentNamespace(string $directory, string|null $prefix = null)
 * @method static void componentNamespace(string $namespace, string $prefix)
 * @method static array getAnonymousComponentPaths()
 * @method static array getAnonymousComponentNamespaces()
 * @method static array getClassComponentNamespaces()
 * @method static void aliasComponent(string $path, string|null $alias = null)
 * @method static void include(string $path, string|null $alias = null)
 * @method static void aliasInclude(string $path, string|null $alias = null)
 * @method static void directive(string $name, callable $handler)
 * @method static array getCustomDirectives()
 * @method static \Illuminate\View\Compilers\BladeCompiler prepareStringsForCompilationUsing(callable $callback)
 * @method static void precompiler(callable $precompiler)
 * @method static void setEchoFormat(string $format)
 * @method static void withDoubleEncoding()
 * @method static void withoutDoubleEncoding()
 * @method static void withoutComponentTags()
 * @method static string getCompiledPath(string $path)
 * @method static bool isExpired(string $path)
 * @method static string newComponentHash(string $component)
 * @method static string compileClassComponentOpening(string $component, string $alias, string $data, string $hash)
 * @method static string compileEndComponentClass()
 * @method static mixed sanitizeComponentAttribute(mixed $value)
 * @method static string compileEndOnce()
 * @method static void stringable(string|callable $class, callable|null $handler = null)
 * @method static string compileEchos(string $value)
 * @method static string applyEchoHandler(string $value)
 *
 * @see \Illuminate\View\Compilers\BladeCompiler
 */
class Blade extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'blade.compiler';
    }
}