Skip to content

Commit 19a9c36

Browse files
authored
Sanitise '-' when using pattern id as theme hook
1 parent edb9ae0 commit 19a9c36

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Definition/PatternDefinition.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public function __construct(array $definition = []) {
6565
$this->id = $this->definition['id'];
6666
$this->setFields($this->definition['fields']);
6767
$this->setVariants($this->definition['variants']);
68-
$this->setThemeHook(self::PATTERN_PREFIX . $this->id());
68+
// As we know allow hyphens the pattern ID, we need to sanitise it when
69+
// setting pattern theme hook.
70+
$hookFriendlyId = str_replace('-', '_', $this->id());
71+
$this->setThemeHook(self::PATTERN_PREFIX . $hookFriendlyId);
6972

7073
if (!empty($definition['theme hook'])) {
7174
$this->setThemeHook($definition['theme hook']);

0 commit comments

Comments
 (0)