From 7c0b360a01afbb30258b5124ae3fedaf016c8c7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sat, 20 Sep 2014 01:00:38 +0200 Subject: [PATCH] ADD: extend table syntax (sprintf string literals): Example: wiki",See also in the %s.?> --- doc/TemplateSyntax.txt | 1 + .../cacert/gigi/output/template/SprintfCommand.java | 2 ++ src/org/cacert/gigi/output/template/Template.java | 12 +++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/TemplateSyntax.txt b/doc/TemplateSyntax.txt index 9309f5e2..47b36e90 100644 --- a/doc/TemplateSyntax.txt +++ b/doc/TemplateSyntax.txt @@ -11,6 +11,7 @@ A template is constructed from a charstream. Everything that is not in " will output the variable "variablename" but not HTML-escaped - will insert the variable "variablename" into the translated text but not HTML-escaped +- will insert "some data" into the translated text literally (not HTML-escaped) - Output/execute the text until "" only if $variable not null or Boolean.FALSE. diff --git a/src/org/cacert/gigi/output/template/SprintfCommand.java b/src/org/cacert/gigi/output/template/SprintfCommand.java index 9cafef47..0275219b 100644 --- a/src/org/cacert/gigi/output/template/SprintfCommand.java +++ b/src/org/cacert/gigi/output/template/SprintfCommand.java @@ -28,6 +28,8 @@ public final class SprintfCommand implements Outputable { String var = myvars[j - 1]; if (var.startsWith("$!")) { Template.outputVar(out, l, vars, myvars[j - 1].substring(2), true); + } else if (var.startsWith("\"")) { + out.print(var.substring(1)); } else { Template.outputVar(out, l, vars, myvars[j - 1].substring(1), false); } diff --git a/src/org/cacert/gigi/output/template/Template.java b/src/org/cacert/gigi/output/template/Template.java index ac59f313..69f17bda 100644 --- a/src/org/cacert/gigi/output/template/Template.java +++ b/src/org/cacert/gigi/output/template/Template.java @@ -121,9 +121,15 @@ public class Template implements Outputable { } else if (s2.startsWith("=s,")) { String command = s2.substring(3); final LinkedList store = new LinkedList(); - while (command.startsWith("$")) { - int idx = command.indexOf(","); - store.add(command.substring(0, idx)); + while (command.startsWith("$") || command.startsWith("\"")) { + int idx; + if (command.startsWith("\"")) { + idx = command.indexOf("\"", 1) + 1; + store.add(command.substring(0, idx - 1)); + } else { + idx = command.indexOf(","); + store.add(command.substring(0, idx)); + } command = command.substring(idx + 1); } final String text = command; -- 2.39.2