Skip to content

Commit

Permalink
FIX: Allow SS4 includes without full path (fixes #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglozzer committed Feb 26, 2021
1 parent 0d5e3bc commit 9821143
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ public static List<SilverstripePsiFile> findIncludeTemplate(Project project, Str

String templatePath = templatePathFragments[1];
// In SS4, we have to make sure the entire path matches. In SS3, just the file name matching is enough
// Special case - "Includes" directory at any level
if (SilverstripeVersionUtil.isSilverstripe4OrMore(project)) {
if (templatePath.equals(key)) {
result.add(file);
} else {
// In SS4, <% include Foo %> should still match "templates/Includes/Foo.ss" without including
// the full path - so we manually inject "Includes/" and check again
int lastSlash = key.lastIndexOf("/");
String includeKey = key.substring(0, lastSlash) + "/Includes/" + key.substring(lastSlash + 1);
if (templatePath.equals(includeKey)) {
result.add(file);
}
}
} else if (templatePath.endsWith(key)) {
result.add(file);
Expand Down

0 comments on commit 9821143

Please sign in to comment.