use of org.eclipse.mylyn.wikitext.mediawiki.TemplateResolver in project mylyn.docs by eclipse.
the class TemplateProcessor method resolveTemplate.
private Template resolveTemplate(String templateName) {
if (!excludePatterns.isEmpty()) {
for (Pattern p : excludePatterns) {
if (p.matcher(templateName).matches()) {
return null;
}
}
}
Template template = templateByName.get(templateName);
if (template == null) {
for (TemplateResolver resolver : mediaWikiLanguage.getTemplateProviders()) {
template = resolver.resolveTemplate(templateName);
if (template != null) {
template = normalize(template);
break;
}
}
if (template == null) {
template = new Template();
template.setName(templateName);
// $NON-NLS-1$
template.setTemplateMarkup("");
}
templateByName.put(template.getName(), template);
}
return template;
}
use of org.eclipse.mylyn.wikitext.mediawiki.TemplateResolver in project mylyn.docs by eclipse.
the class TemplateProcessorTest method testCaseSensitivity.
public void testCaseSensitivity() {
// bug 323224
final Set<String> templateNames = new HashSet<String>();
markupLanguage.getTemplateProviders().add(new TemplateResolver() {
@Override
public Template resolveTemplate(String templateName) {
templateNames.add(templateName);
Template template = new Template();
template.setName(templateName);
template.setTemplateMarkup("test");
return template;
}
});
String[] names = new String[] { "One", "one", "OneTwo", "onetwo", "oneTwo" };
for (String name : names) {
templateNames.clear();
TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
templateProcessor.processTemplates("content {{" + name + "}} more");
assertContains(templateNames, name);
assertEquals(1, templateNames.size());
}
}
Aggregations