Add template & scss syntax to refer to absolute paths within Rhymix installation directory

템플릿을 인클루드하거나 CSS, JS 등을 로딩할 때 다른 경로에 있는 파일을 상대경로로 참조하려고 하면
../../../../../layouts/path/to/target/asset.scss 처럼 상당히 많이 거슬러 올라가야 하는 경우가 있습니다.
이 때 맨 앞에 ^를 붙여 ^/layouts/path/to/target/asset.scss 라고 마치 절대경로처럼 쓰면
라이믹스 설치 경로 기준으로 (서브폴더에 설치한 경우 포함) 자동으로 변환하도록 하는 패치입니다.
즉 ^ 문자를 넣은 부분이 라이믹스 설치 경로로 치환된다고 보면 됩니다.

지원되는 곳:
  - <include target="^/path/to/file.html" />
  - <load target="^/path/to/file.css" />
  - <load target="^/path/to/file.js" />
  - SCSS에서 @import "^/path/to/file.scss";
This commit is contained in:
Kijin Sung 2022-10-13 14:57:24 +09:00
parent fd421c86fc
commit d2347d4208
2 changed files with 34 additions and 10 deletions

View file

@ -374,7 +374,15 @@ class Formatter
{
$basename = '_' . $basename . '.scss';
}
return $dirname . '/' . substr($str, 0, $dirpos) . '/' . $basename;
$basepath = substr($str, 0, $dirpos);
if (preg_match('!^\\^/(.+)!', $basepath, $bpmatches))
{
return \RX_BASEDIR . $bpmatches[1] . '/' . $basename;
}
else
{
return $dirname . '/' . $basepath . '/' . $basename;
}
}
else
{
@ -388,7 +396,7 @@ class Formatter
}
else
{
return dirname($filename) . '/' . $str;
return $dirname . '/' . $str;
}
}, explode(',', $matches[1]));
foreach ($import_files as $import_filename)