Cases.php in Minify Source HTML 8
File
tests/modules/minifyhtml_test/src/Controller/Cases.php
View source
<?php
namespace Drupal\minifyhtml_test\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\HtmlResponse;
class Cases extends ControllerBase {
public function item($case) {
$input = '';
switch ($case) {
case 'textarea_replacement':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= " <textarea cols=\"55\" rows=\"31\">\n";
$input .= "Content in here will not matter.\n";
$input .= "Even multiline content.\n";
$input .= "</textarea>\n";
$input .= " </body>\n";
$input .= "</html>\n";
break;
case 'pre_replacement':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= " <pre>\n";
$input .= " Indented content.\n";
$input .= " Weirdly Indented content.\n";
$input .= "Non-indented content.\n";
$input .= "</pre>\n";
$input .= " </body>\n";
$input .= "</html>\n";
break;
case 'iframe_replacement':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= " <iframe src=\"\" width=\"100\" height=\"100\" ></iframe>\n";
$input .= " </body>\n";
$input .= "</html>\n";
break;
case 'script_replacement':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= " <script>\n";
$input .= "alert('test');\n";
$input .= " </script>\n";
$input .= " </body>\n";
$input .= "</html>\n";
break;
case 'style_replacement':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= " <style>\n";
$input .= "body { color: #fff; }\n";
$input .= " </style>\n";
$input .= " </body>\n";
$input .= "</html>\n";
break;
case 'comment_stripping':
$input .= "<html>\n";
$input .= " <head>\n";
$input .= " <title>Test HTML</title>\n";
$input .= " </head>\n";
$input .= " <body>\n";
$input .= "<!-- The body goes here //-->";
$input .= " </body>\n";
$input .= "</html>\n";
break;
}
return HtmlResponse::create($input);
}
}