Skip to content

Commit

Permalink
Merge pull request #1553 from hydephp/improved-includes
Browse files Browse the repository at this point in the history
Simplify the includes facade documentation
  • Loading branch information
caendesilva authored Feb 12, 2024
2 parents 56242ab + f41a3a3 commit 9e1d717
Showing 1 changed file with 16 additions and 40 deletions.
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

0 comments on commit 9e1d717

Please sign in to comment.