Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the includes facade documentation #1553

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 16 additions & 40 deletions docs/digging-deeper/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,62 +48,38 @@ Includes are stored in the `resources/includes` directory. You can access them u
```php
use Hyde\Support\Includes;

// Get the raw contents of any arbitrary file in the includes directory
Includes::get('example.md');
Includes::get('example.md', 'Default content');
```

### Markdown Includes

Gets the rendered Markdown of a partial file in the includes directory. Supplying the file extension is optional.
// Get the raw contents of an HTML file in the includes directory
Includes::html('example.html');

```php
use Hyde\Support\Includes;
// Get the rendered Blade of a partial file in the includes directory
Includes::blade('example.blade.php');

Includes::markdown('footer');
Includes::markdown('footer.md');

// With default value if the file does not exist
Includes::markdown('footer', 'Default content');
// Get the rendered Markdown of a partial file in the includes directory
Includes::markdown('example.md');
```

### Blade Includes

Gets the rendered Blade of a partial file in the includes directory. Supplying the file extension is optional.
When using the `html`, `markdown`, and `blade` methods, the file extension is optional.

```php
use Hyde\Support\Includes;

Includes::blade('banner');
Includes::blade('banner.blade.php');

// With default value if the file does not exist
Includes::blade('banner', 'Default content');
Includes::html('example') === Includes::html('example.html');
Includes::blade('example') === Includes::blade('example.blade.php');
Includes::markdown('example') === Includes::markdown('example.md');
```

### HTML Includes

Gets the raw HTML of a partial file in the includes directory. Supplying the file extension is optional.
All methods will return `null` if the file does not exist.
However, you can supply a default value as the second argument to be used instead.
Remember that Markdown and Blade defaults will still be rendered to HTML.

```php
use Hyde\Support\Includes;

Includes::html('footer');
Includes::html('footer.html');

// With default value if the file does not exist
Includes::html('footer', 'Default content');
```

### Directory Structure Example

Here is an example of the directory structure for includes:

```tree
resources/
|-- includes/
| |-- example.md
| |-- footer.md
| |-- banner.blade.php
// If the file does not exist, the default value will be returned
Includes::markdown('example.md', 'Default content');
```

### Stock Includes
Expand Down
Loading