zloynick/joole-components-renderer

8.1.3.1 2022-05-03 22:26 UTC

This package is not auto-updated.

Last update: 2025-06-26 11:50:44 UTC


README

This component is an implementation of the html content renderer.

Getting started

  • Install this dependency via composer: composer install zloynick/joole-components-renderer

Configuration

Add to components this in your joole.php configuration file:


'components' => [
        ...,
        [
            'name' => 'renderer',
            'class' => \joole\components\renderer\RendererComponent::class,
            // Component options
            'options' => [
                // Views path
                'views' => __DIR__.'/../views/',
            ],
        ],
        ...,
    ],

Using

Views

Create your first view file:

----------index.php-----------

...
/** @var array $rating */

foreach($rating as $place => $name){
...
}
...

Rendering with params

Every param name is variable, that can be used in view file.


$viewObject = \joole\framework\Joole::$app->getRenderer()->renderView('index.php', [
    'rating' => ['Anastasia', 'Mikhail', 'Artem'],
]);

JS/CSS rendering

You can also add CSS/JS content to view:


...
$viewObject->renderJs(' console.log("Hello, world!")) ');
$viewObject->renderCss('body{ background-color: #c0c0c0 }');
...