import java.io.Reader;
import java.net.URISyntaxException;
import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.LinkedList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.output.DateSelector;
import org.cacert.gigi.util.HTMLEncoder;
public class Template implements Outputable {
- class ParseResult {
+ private static class ParseResult {
TemplateBlock block;
private File source;
- private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-z]+)\\(\\$([^)]+)\\) ?\\{ ?");
+ private static final Pattern CONTROL_PATTERN = Pattern.compile(" ?([a-zA-Z]+)\\(\\$([^)]+)\\) ?\\{ ?");
private static final Pattern ELSE_PATTERN = Pattern.compile(" ?\\} ?else ?\\{ ?");
}
if (s instanceof Outputable) {
((Outputable) s).output(out, l, vars);
+ } else if (s instanceof java.sql.Date) {
+ out.print(DateSelector.getDateFormat().format(s));
+ } else if (s instanceof Date) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ out.print(sdf.format(s));
+ out.print(" UTC");
} else {
out.print(s == null ? "null" : (unescaped ? s.toString() : HTMLEncoder.encodeHTML(s.toString())));
}