Skip to content

Leading slash in theme paths #328

Description

@donquixote

See my comment in #298 (comment).

I defined a pattern in a module using a yml file, and I noticed that the theme hook had a path starting with a leading slash.
E.g. /modules/custom/my_module/templates/patterns/my_pattern/pattern-my-pattern.html.twig.
The problem seems to be the str_replace() in PatternBase and LibraryPattern, which is meant to remove the absolute part from the pattern path.

$definition_base_path = '/var/www/html/web/modules/custom/my_patterns/templates/patterns/my_pattern';
$root = '/var/www/html/web';
$path = str_replace($root, '', $definition_base_path);
print $path === '/modules/custom/my_patterns/templates/patterns/my_pattern' ? 'problem' : 'ok';

I am a bit confused why this was not reported as broken before. Am I doing something wrong?

Going to post a minimal PR and we'll see which test blows up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions