info.bliki.wiki.template.UCFirst Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bliki-core Show documentation
Show all versions of bliki-core Show documentation
This is the core project.
The newest version!
package info.bliki.wiki.template;
import info.bliki.wiki.model.IWikiModel;
import java.util.List;
/**
* A template parser function for {{ucfirst: ... }}
first
* character to upper case syntax. See Wikipedia -
* Help:Variable#Formatting
*
*/
public class UCFirst extends AbstractTemplateFunction {
public final static ITemplateFunction CONST = new UCFirst();
@Override
public String parseFunction(List list, IWikiModel model, char[] src, int beginIndex, int endIndex, boolean isSubst) {
if (list.size() > 0) {
String word = isSubst ? list.get(0) : parseTrim(list.get(0), model);
if (word.length() > 0) {
return Character.toUpperCase(word.charAt(0)) + word.substring(1);
}
return "";
}
return null;
}
}