aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/main.js12
-rw-r--r--include/template_processor.php9
2 files changed, 14 insertions, 7 deletions
diff --git a/include/main.js b/include/main.js
index 31b441afb..1a377a1a4 100644
--- a/include/main.js
+++ b/include/main.js
@@ -307,3 +307,15 @@
});
}
+/**
+ * sprintf in javascript
+ * "{0} and {1}".format('zero','uno');
+ **/
+String.prototype.format = function() {
+ var formatted = this;
+ for (var i = 0; i < arguments.length; i++) {
+ var regexp = new RegExp('\\{'+i+'\\}', 'gi');
+ formatted = formatted.replace(regexp, arguments[i]);
+ }
+ return formatted;
+};
diff --git a/include/template_processor.php b/include/template_processor.php
index be40a31ab..3f79ed593 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -71,11 +71,7 @@
} else {
$val = $this->_get_var($args[2]);
}
- if (isset($args[4])) {
- list($strue, $sfalse)= explode($args[4], $args[3]);
- } else {
- $strue = $args[3]; $sfalse = "";
- }
+ list($strue, $sfalse)= preg_split("|{{ *else *}}|", $args[3]);
return ($val?$strue:$sfalse);
}
@@ -135,7 +131,6 @@
$s = "";
}
$s = preg_replace_callback('/\|\|([0-9]+)\|\|/', array($this, "_replcb_node"), $s);
- if ($s==Null) $this->_preg_error()
return $s;
}
@@ -168,7 +163,7 @@
#$s = str_replace(array("\n","\r"),array("§n§","§r§"),$s);
$s = $this->_build_nodes($s);
$s = preg_replace_callback('/\|\|([0-9]+)\|\|/', array($this, "_replcb_node"), $s);
- if ($s==Null) $this->_preg_error()
+ if ($s==Null) $this->_preg_error();
$s = str_replace($this->search,$this->replace, $s);
return $s;