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

FluidTYPO3 / vhs / 30001290505

23 Jul 2026 10:57AM UTC coverage: 70.309% (-1.7%) from 72.022%
30001290505

push

github

NamelessCoder
[TER] 8.0.0

4819 of 6854 relevant lines covered (70.31%)

6.54 hits per line

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

64.29
/Classes/ViewHelpers/Format/TidyViewHelper.php
1
<?php
2
namespace FluidTYPO3\Vhs\ViewHelpers\Format;
3

4
/*
5
 * This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use FluidTYPO3\Vhs\Core\ViewHelper\AbstractViewHelper;
12
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
13

14
/**
15
 * Tidy-processes a string (HTML source), applying proper
16
 * indentation.
17
 */
18
class TidyViewHelper extends AbstractViewHelper
19
{
20
    /**
21
     * @var boolean
22
     */
23
    protected $escapeOutput = false;
24

25
    public function initializeArguments(): void
26
    {
27
        $this->registerArgument('content', 'string', 'Content to tidy');
3✔
28
        $this->registerArgument('encoding', 'string', 'Encoding of string', false, 'utf8');
3✔
29
    }
30

31
    /**
32
     * @return string|\tidy
33
     */
34
    public static function renderStatic(
35
        array $arguments,
36
        \Closure $renderChildrenClosure,
37
        RenderingContextInterface $renderingContext
38
    ) {
39
        /** @var string $content */
40
        $content = $arguments['content'] ?? $renderChildrenClosure();
6✔
41
        /** @var string $encoding */
42
        $encoding = $arguments['encoding'];
6✔
43
        if (class_exists('tidy')) {
6✔
44
            $tidy = tidy_parse_string($content, [], $encoding);
6✔
45
            if ($tidy === false) {
6✔
46
                return $content;
×
47
            }
48
            $tidy->cleanRepair();
6✔
49
            return $tidy->root()->value;
6✔
50
        }
51
        throw new \RuntimeException(
×
52
            'TidyViewHelper requires the PHP extension "tidy" which is not installed or not loaded.',
×
53
            1352059753
×
54
        );
×
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc