A flexible and intuitive templating engine for PHP, optimized for use with the Fastpress framework. Provides an easy-to-use interface for rendering views, handling layouts, and managing content blocks.

0.1.2 2024-09-15 11:14 UTC

This package is auto-updated.

Last update: 2024-10-15 11:29:34 UTC


README

Fastpress View is a powerful and flexible templating engine for PHP, designed to render views and manage layouts seamlessly within the Fastpress framework.

Installation

Use Composer to install Fastpress View into your project:

composer require fastpress/view

Usage

Creating an Instance

You can create an instance of the View class by passing the application context or configuration array.

$app = ['template' => ['views' => '/path/to/views/', 'layout' => '/path/to/layout/']];
$view = new \Fastpress\View\View($app);

Setting Configuration Options

Set configuration options using the set method:

$view->set('option', 'value');

Rendering Views

Render a view file with optional variables:

$view->render('viewFile.php', ['variable' => 'value']);

Extending Layouts

Extend an existing layout file:

$view->extend('layoutFile');

Managing Content Blocks

Start and end content blocks within your layout:

$view->block('blockName');
// ... HTML and PHP content here ...
$view->endblock('blockName');

Retrieve the content of a named block:

$view->content('blockName');

Setting and Retrieving Layouts

Set a layout file:

$view->layout('layoutFile');

Contributing

Contributions are welcome! Please feel free to submit a pull request or open issues to improve the library.

License

This library is open-sourced software licensed under the MIT license.

Support

If you encounter any issues or have questions, please file them in the issues section on GitHub.