# Render

This class provides methods for rendering views, layouts, components, blocks, and managing assets (CSS, JS).

## `asset()`

```php
function asset($assetType, $file, $options = [])
```

* `$assetType`- 'css' or 'js'
* `$file`- File name (relative path from the Assets directory in the view)
* `$options`- Options array including:
  * 'area': (default 'frontend')
    * 'location': (default 'head' or 'footer')

Example:

```php
<?php
Render::asset('css', 'styles.css', ['area' => 'frontend', 'location' => 'head']);
Render::asset('js', 'main.js', ['area' => 'frontend', 'location' => 'footer']);

// Make sure CSS and JS files are contained in Views/Fronted/Assets/ folder
```

## `renderAsset()`

```php
function renderAsset($location = 'head', $area = 'frontend')
```

* `$location`- 'head' or 'footer'
* `$area` - 'frontend' or 'backend'
* `return` - Resulting HTML.

Example:

```php
<?php
echo Render::renderAsset('head', 'frontend');
echo Render::renderAsset('footer', 'frontend');
```

## `render()`

```php
function render($layout, $view = null, $data = [])
```

* `$layout` - Name of the layout to load (e.g., 'layout' or 'layout2')
* `$view` - Name of the view to load (e.g., 'home/home')
* `$data`- Data to pass to the view
* `return` - The buffered output as a string.

Example:

```php
<?php
$data = ['title' => 'Home Page', 'content' => 'Welcome to the PHPFast Framework!'];
echo Render::render('main', 'home/index', $data);

// Render the main layout with the home/index view, passing the provided data to the view.
```

## `html()`

```php
function html($layout, $data = [])
```

* `$layout` - Name of the layout to load (e.g., 'layout' or 'layout2')
* `$data`-  Data to pass to the view
* `return` - The buffered output as a string.

Example:

```php
<?php
$data = ['title' => 'Home Page', 'content' => 'Welcome to the PHPFast Framework!'];
echo Render::html('content', $data);

// Render the main layout, passing the provided data to the layout.
```

## `component()`

```php
function component($component, $data = [])
```

* `$component`- Name of the component to render (e.g., 'header', 'footer')
* `$data`- Data to pass to the component
* `return` - The buffered output as a string.

Example:

```php
<?php
$data = ['title' => 'Home Page'];
echo Render::component('header', $data);

// Render a component named header with some data
```

## `block()`

```php
function block($blockName, $data = [])
```

* `$blockName`- Name of the Block, can be capitalized or lowercase
* `$data`- Additional props parameters of the Block, if not provided, Default will be used
* `return` -  The block instance.

Example:

```php
<?php
$data = ['title' => 'PHPFast', 'description' => 'PHPFast is a fast Framework!!!'];
echo Render::block('head', $data);

// Render a block named head with some data
```

## `getblock()`

```php
function getblock($blockName)
```

* `$blockName`- Name of the Block, can be capitalized or lowercase
* `return` -  The block instance or null if the class does not exist.

Example:

```php
<?php
$block = Render::getblock('head');

// Get an instance of a block named example
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cmsfullform.com/documents/libraries/render.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
