• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CPS-IT / handlebars / 23430176268

23 Mar 2026 09:24AM UTC coverage: 89.755% (-0.1%) from 89.861%
23430176268

push

github

web-flow
Merge pull request #547 from CPS-IT/renovate/devtheorem-php-handlebars-1.x

[TASK] Update devtheorem/php-handlebars to v1

10 of 12 new or added lines in 5 files covered. (83.33%)

1358 of 1513 relevant lines covered (89.76%)

6.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/Classes/Renderer/Helper/BlockHelper.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3Handlebars\Renderer\Helper;
19

20
use CPSIT\Typo3Handlebars\Attribute;
21
use CPSIT\Typo3Handlebars\Renderer;
22
use DevTheorem\Handlebars;
23

24
/**
25
 * BlockHelper
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 * @see https://github.com/shannonmoeller/handlebars-layouts#block-name
30
 */
31
#[Attribute\AsHelper('block')]
32
final readonly class BlockHelper implements Helper
33
{
34
    public function render(Handlebars\HelperOptions $options, string $name = ''): string
2✔
35
    {
36
        $actions = [];
2✔
37
        $layoutStack = Renderer\Component\Layout\HandlebarsLayoutStack::fromScope($options->scope);
2✔
38

39
        // Parse layouts and fetch all parsed layout actions for the requested block
40
        foreach ($layoutStack as $layout) {
2✔
41
            if (!$layout->isParsed()) {
1✔
42
                $layout->parse($options->scope);
1✔
43
            }
44

45
            foreach ($layout->getActions($name) as $action) {
1✔
46
                $actions[] = $action;
1✔
47
            }
48
        }
49

50
        try {
51
            $initial = $options->fn($options->scope);
2✔
NEW
52
        } catch (\Exception) {
×
NEW
53
            $initial = '';
×
54
        }
55

56
        // Walk through layout actions and apply them to the rendered block
57
        return array_reduce(
2✔
58
            $actions,
2✔
59
            static fn(string $value, Renderer\Component\Layout\HandlebarsLayoutAction $action): string => $action->render($value),
2✔
60
            $initial,
2✔
61
        );
2✔
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc