- String[] parts = l.getTranslation(text).split("%s");
- String[] myvars = store.toArray(new String[store.size()]);
- out.print(parts[0]);
- for (int j = 1; j < parts.length; j++) {
- Template.outputVar(out, l, vars, myvars[j - 1].substring(1));
- out.print(parts[j]);
+ String parts = l.getTranslation(text);
+ Matcher m = replacant.matcher(parts);
+ int pos = 0;
+ while (m.find()) {
+ out.print(HTMLEncoder.encodeHTML(parts.substring(pos, m.start())));
+ String var = store[Integer.parseInt(m.group(1))];
+ if (var.startsWith("$!")) {
+ Template.outputVar(out, l, vars, var.substring(3, var.length() - 1), true);
+ } else if (var.startsWith("!'")) {
+ out.print(var.substring(2));
+ } else if (var.startsWith("$")) {
+ Template.outputVar(out, l, vars, var.substring(2, var.length() - 1), false);
+ } else {
+ throw new Error("Processing error in template.");
+ }
+ pos = m.end();
+