]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/output/template/OutputVariableCommand.java
upd: rename package name and all references to it
[gigi.git] / src / club / wpia / gigi / output / template / OutputVariableCommand.java
diff --git a/src/club/wpia/gigi/output/template/OutputVariableCommand.java b/src/club/wpia/gigi/output/template/OutputVariableCommand.java
new file mode 100644 (file)
index 0000000..54f8dca
--- /dev/null
@@ -0,0 +1,42 @@
+package club.wpia.gigi.output.template;
+
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Map;
+
+import club.wpia.gigi.localisation.Language;
+
+/**
+ * Emits a variable.
+ */
+public final class OutputVariableCommand implements Translatable {
+
+    private final String raw;
+
+    private final boolean unescaped;
+
+    /**
+     * Creates a new OutputVariableCommand.
+     * 
+     * @param raw
+     *            the variable to emit. If starting with <code>!</code> the
+     *            variable is emitted non-HTML-escaped.
+     */
+    public OutputVariableCommand(String raw) {
+        if (raw.charAt(0) == '!') {
+            unescaped = true;
+            this.raw = raw.substring(1);
+        } else {
+            unescaped = false;
+            this.raw = raw;
+        }
+    }
+
+    @Override
+    public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+        Template.outputVar(out, l, vars, raw, unescaped);
+    }
+
+    @Override
+    public void addTranslations(Collection<String> s) {}
+}