public class DollarContext extends AbstractTemplateFunction
{{#$:object|formatstring|separator|null-value}}.
Example:
public void testRendererForST() throws Exception {
wikiModel.setAttribute("created", new GregorianCalendar(2005, 07 - 1, 05));
wikiModel.registerRenderer(GregorianCalendar.class, wikiModel.new DateRenderer());
String expecting = "date: 2005.07.05";
assertEquals(expecting, wikiModel.parseTemplates("date: {{#$:created}}"));
}
public class DateRenderer implements AttributeRenderer {
public String toString(Object o) {
SimpleDateFormat f = new SimpleDateFormat("yyyy.MM.dd");
return f.format(((Calendar) o).getTime());
}
public String toString(Object o, String formatString) {
return toString(o);
}
}
| Modifier and Type | Field and Description |
|---|---|
static ITemplateFunction |
CONST |
| Constructor and Description |
|---|
DollarContext() |
| Modifier and Type | Method and Description |
|---|---|
String |
parseFunction(List<String> list,
IWikiModel model,
char[] src,
int beginIndex,
int endIndex,
boolean isSubst)
Parse a template function (like for example
{{ #if: ... |
getFunctionDoc, parse, parseTrimpublic static final ITemplateFunction CONST
public String parseFunction(List<String> list, IWikiModel model, char[] src, int beginIndex, int endIndex, boolean isSubst) throws IOException
AbstractTemplateFunction{{ #if: ... }}).
The result is also a text string in Wikipedia syntax notation which will be
parsed again (recursively) in the TemplateParser step.parseFunction in interface ITemplateFunctionparseFunction in class AbstractTemplateFunctionlist - the parser function arguments (extracted from the wiki text by
splitting the string at the pipe symbol ´|´)model - the wiki modelsrc - the array of the current Wikipedia source text.beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.isSubst - if true the template function was called from
subst or safesubst function and the arguments of
the function are typically not parsed recursively.null if
the parsing fails or isn't valid.IOExceptionTemplateParser#parseTemplate(StringBuffer)Copyright © 2017 Java Wikipedia API (Bliki engine). All rights reserved.