Skip to content

Commit e4a987d

Browse files
committed
Changes pattern render from markup to inline
fix(PatternkitBlock.php)
1 parent 0557a39 commit e4a987d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Plugin/Block/PatternkitBlock.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ public function build() {
387387
$library_plugin = $this->patternLibraryPluginManager->createInstance($library_plugin_id);
388388
$elements = $library_plugin->render([$pattern]);
389389

390+
// @todo If context is available, tokenize context instead of the template.
391+
// This is mostly useful for twig-based libraries.
390392
$markup = '';
391393
foreach ($elements as $element) {
392394
// Replace context tokens.
@@ -418,7 +420,10 @@ public function build() {
418420
}
419421

420422
$content = [
421-
'#markup' => $markup,
423+
'pattern' => [
424+
'#type' => 'inline_template',
425+
'#template' => $markup,
426+
],
422427
'#attached' => $config['pkdata']['attachments'] ?? [],
423428
];
424429
// Save to the cache bin (if caching is enabled).

src/Plugin/PatternLibrary/PatternLibraryTwig.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public static function create(ContainerInterface $container, array $configuratio
5959
* {@inheritdoc}
6060
*
6161
* @throws \Throwable
62+
*
63+
* @todo Return render arrays for Twig only.
6264
*/
6365
public function render(array $assets): array {
6466
$elements = [];

0 commit comments

Comments
 (0)