mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
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:
parent
fd421c86fc
commit
d2347d4208
2 changed files with 34 additions and 10 deletions
|
|
@ -831,8 +831,16 @@ class TemplateHandler
|
|||
return '';
|
||||
}
|
||||
|
||||
$pathinfo = pathinfo($attr['target']);
|
||||
$fileDir = $this->_getRelativeDir($pathinfo['dirname']);
|
||||
if (preg_match('!^\\^/(.+)!', $attr['target'], $tmatches))
|
||||
{
|
||||
$pathinfo = pathinfo(\RX_BASEDIR . $tmatches[1]);
|
||||
$fileDir = $pathinfo['dirname'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$pathinfo = pathinfo($attr['target']);
|
||||
$fileDir = $this->_getRelativeDir($pathinfo['dirname']);
|
||||
}
|
||||
|
||||
if(!$fileDir)
|
||||
{
|
||||
|
|
@ -865,20 +873,28 @@ class TemplateHandler
|
|||
|
||||
if(!$isRemote)
|
||||
{
|
||||
if(!preg_match('@^\.?/@', $attr['target']))
|
||||
if (preg_match('!^\\^/(.+)!', $attr['target'], $tmatches))
|
||||
{
|
||||
$attr['target'] = './' . $attr['target'];
|
||||
$pathinfo = pathinfo($tmatches[1]);
|
||||
$relativeDir = $pathinfo['dirname'];
|
||||
$attr['target'] = $relativeDir . '/' . $pathinfo['basename'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!preg_match('@^\.?/@', $attr['target']))
|
||||
{
|
||||
$attr['target'] = './' . $attr['target'];
|
||||
}
|
||||
$relativeDir = $this->_getRelativeDir($pathinfo['dirname']);
|
||||
$attr['target'] = $relativeDir . '/' . $pathinfo['basename'];
|
||||
}
|
||||
|
||||
if(substr($attr['target'], -5) == '/lang')
|
||||
{
|
||||
$pathinfo['dirname'] .= '/lang';
|
||||
$pathinfo['basename'] = '';
|
||||
$pathinfo['extension'] = 'xml';
|
||||
}
|
||||
|
||||
$relativeDir = $this->_getRelativeDir($pathinfo['dirname']);
|
||||
|
||||
$attr['target'] = $relativeDir . '/' . $pathinfo['basename'];
|
||||
}
|
||||
|
||||
switch($pathinfo['extension'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue