Skip to content

Commit

Permalink
Sanitise '-' when using pattern id as theme hook
Browse files Browse the repository at this point in the history
  • Loading branch information
gambry authored Sep 5, 2019
1 parent edb9ae0 commit 19a9c36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Definition/PatternDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public function __construct(array $definition = []) {
$this->id = $this->definition['id'];
$this->setFields($this->definition['fields']);
$this->setVariants($this->definition['variants']);
$this->setThemeHook(self::PATTERN_PREFIX . $this->id());
// As we know allow hyphens the pattern ID, we need to sanitise it when
// setting pattern theme hook.
$hookFriendlyId = str_replace('-', '_', $this->id());
$this->setThemeHook(self::PATTERN_PREFIX . $hookFriendlyId);

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

0 comments on commit 19a9c36

Please sign in to comment.