Skip to content

Commit 0a042c0

Browse files
committed
IFeature to inject TS into styleguide rendering
1 parent e6d05b0 commit 0a042c0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Classes/Middleware/StyleguideRouter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
2121
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
2222
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript;
23+
use TYPO3\CMS\Core\TypoScript\TypoScriptStringFactory;
2324
use TYPO3\CMS\Core\Utility\GeneralUtility;
2425
use TYPO3\CMS\Core\View\ViewFactoryData;
2526
use TYPO3\CMS\Core\View\ViewFactoryInterface;
@@ -152,6 +153,16 @@ public function process(
152153
$plainFrontendTypoScript->setSetupArray([]);
153154
}
154155

156+
$typoScriptPath = $this->extensionConfiguration->get('fluid_styleguide', 'typoScriptPath');
157+
if (!empty($typoScriptPath)) {
158+
$typoScriptPath = GeneralUtility::getFileAbsFileName($typoScriptPath);
159+
$typoScriptContent = file_get_contents($typoScriptPath);
160+
$typoScriptStringFactory = GeneralUtility::makeInstance(TypoScriptStringFactory::class);
161+
$ast = $typoScriptStringFactory->parseFromStringWithIncludes('fluid-styleguide', $typoScriptContent);
162+
$plainFrontendTypoScript->setSetupTree($ast);
163+
$plainFrontendTypoScript->setSetupArray($ast->toArray());
164+
}
165+
155166
$request = $request->withAttribute('frontend.typoscript', $plainFrontendTypoScript);
156167

157168
// Create view

ext_conf_template.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# cat=general; type=string; label=URI prefix that should display the styleguide: Advanced! Only change this property if you know what you're doing!
22
uriPrefix = /fluid-styleguide/
3+
4+
# cat=general; type=string; label=Path to TypoScript: This file is being loaded for the styleguide rendering. Might contain 'lib.parseFunc_RTE' and other necessary TS objects.
5+
typoscriptPath =

0 commit comments

Comments
 (0)