mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fix errors if empty array passed for vars in Requirements_Backend::javascriptTemplate()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71905 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0b9db33164
commit
5012fcb3ca
@ -427,10 +427,14 @@ class Requirements_Backend {
|
|||||||
*/
|
*/
|
||||||
function javascriptTemplate($file, $vars, $uniquenessID = null) {
|
function javascriptTemplate($file, $vars, $uniquenessID = null) {
|
||||||
$script = file_get_contents(Director::getAbsFile($file));
|
$script = file_get_contents(Director::getAbsFile($file));
|
||||||
foreach($vars as $k => $v) {
|
$search = array();
|
||||||
|
$replace = array();
|
||||||
|
|
||||||
|
if($vars) foreach($vars as $k => $v) {
|
||||||
$search[] = '$' . $k;
|
$search[] = '$' . $k;
|
||||||
$replace[] = str_replace("\\'","'", Convert::raw2js($v));
|
$replace[] = str_replace("\\'","'", Convert::raw2js($v));
|
||||||
}
|
}
|
||||||
|
|
||||||
$script = str_replace($search, $replace, $script);
|
$script = str_replace($search, $replace, $script);
|
||||||
$this->customScript($script, $uniquenessID);
|
$this->customScript($script, $uniquenessID);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user