# Blade Views in NovaBuilder

## Directory structure

```text
app/Views/
├─ layouts/
│  ├─ main.blade.php
│  ├─ admin.blade.php
│  └─ auth.blade.php
├─ home/
├─ auth/
└─ admin/
```

## Layout inheritance

```blade
@extends('layouts.main')

@section('content')
    <h1>{{ $title }}</h1>
@endsection
```

The layouts expose the main page slot with:

```blade
@yield('content')
```

## Output

Escaped output (recommended for user/content data):

```blade
{{ $title }}
```

Raw HTML output (only for trusted/sanitized HTML):

```blade
{!! $html !!}
```

## Control directives

The Composer BladeOne engine supports normal Blade-style directives. The built-in fallback supports the directives used by the project plus common directives such as `@if`, `@foreach`, `@for`, `@while`, `@isset`, `@empty`, `@php`, `@csrf`, `@extends`, `@section`, and `@yield`.

## Composer

Optional but recommended:

```bash
composer install
```

NovaBuilder then automatically uses `eftec/bladeone`. Without Composer, the built-in fallback keeps the project runnable.

## Cache

Compiled views are written to:

```text
storage/cache/views/
```

Delete generated `.php` files in that directory if you want to force recompilation. Do not remove `.gitkeep`.
## Static page registry

Drop-in static pages live in:

```text
app/Views/static-pages/*.blade.php
```

A file is registered automatically and appears in **Admin → Page Management**. The filename becomes the default public slug. Optional metadata may be added in the first Blade comment:

```blade
{{--
@static-page
title: Example page
slug: example-page
status: published
language: fa
layout: main
seo_title: Example page | ITX Trade
seo_description: Example description
--}}
```

`layout: main` is the default and applies the shared site header/footer even when the file does not explicitly use `@extends`. Use `layout: none` for a full standalone document. Files beginning with `_` and files containing `@static-ignore` in the first Blade comment are ignored.

The registry is deliberately flat: only files directly inside `static-pages` are scanned. Database-managed pages take precedence over files with the same slug. Static files can be converted non-destructively into **Managed Blade Pages**, after which their source is editable from the admin code editor while the original file remains as fallback. Source viewing, draft preview, conversion, and Managed Blade code editing are restricted to the `admin` role because Blade source can execute PHP.

