-
-
Save aiphee/021a683e139f6cd16bb668d1440ad0db to your computer and use it in GitHub Desktop.
Simple component test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{include ../../../Components/ProductTile/templates/test-block.latte with blocks} | |
{for $i = 0; $i < 500; $i++} | |
{include ptBlock 'index' => $i} | |
{/for} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Presenters; | |
use App\Components\ProductTile\ProductTileComponent; | |
use Nette; | |
use Nette\Application\UI\Multiplier; | |
final class HomePresenter extends Nette\Application\UI\Presenter | |
{ | |
protected function createComponentProductTile(): Nette\Application\UI\Multiplier | |
{ | |
return new Multiplier(fn(string $key) => new ProductTileComponent((int) $key)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{block content} | |
{for $i = 0; $i < 500; $i++} | |
{include ../../../Components/ProductTile/templates/test.latte 'index' => $i} | |
{/for} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Components\ProductTile; | |
use Nette\Application\UI\Control; | |
class ProductTileComponent extends Control | |
{ | |
public function __construct( | |
private readonly int $index, | |
) { | |
} | |
public function render(): void | |
{ | |
$this->template->render( | |
__DIR__ . '/templates/test.latte', | |
[ | |
'index' => $this->index, | |
] | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{define ptBlock} | |
<div> | |
<h3>{$index}</h3> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum eligendi enim est eum expedita iste nam nesciunt | |
numquam omnis, optio, quod recusandae repellendus saepe similique sint tenetur ullam ut voluptas. | |
</div> | |
{/define} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<h3>{$index}</h3> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Earum eligendi enim est eum expedita iste nam nesciunt | |
numquam omnis, optio, quod recusandae repellendus saepe similique sint tenetur ullam ut voluptas. | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment