Search in sources :

Example 31 with Template

use of org.eclipse.mylyn.wikitext.mediawiki.Template in project mylyn.docs by eclipse.

the class TemplateProcessorTest method testBasicTemplatesNoParametersRecLoopDetection.

public void testBasicTemplatesNoParametersRecLoopDetection() {
    // Bug 379783
    Template template1 = new Template();
    template1.setName("rec_a");
    template1.setTemplateMarkup("+ rec_a {{rec_b}} rec_a +");
    markupLanguage.getTemplates().add(template1);
    Template template2 = new Template();
    template2.setName("rec_b");
    template2.setTemplateMarkup("+ rec_b {{rec_c}} rec_b +");
    markupLanguage.getTemplates().add(template2);
    Template template3 = new Template();
    template3.setName("rec_c");
    template3.setTemplateMarkup("+ rec_c {{rec_a}} rec_c +");
    markupLanguage.getTemplates().add(template3);
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("{{rec_a}}");
    assertEquals("+ rec_a + rec_b + rec_c <span class=\"error\">Template loop detected:rec_a</span> rec_c + rec_b + rec_a +", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 32 with Template

use of org.eclipse.mylyn.wikitext.mediawiki.Template in project mylyn.docs by eclipse.

the class TemplateProcessorTest method testBasicTemplatesNoParametersRec.

public void testBasicTemplatesNoParametersRec() {
    // Bug 379783
    Template templateFoo = new Template();
    templateFoo.setName("foo");
    templateFoo.setTemplateMarkup("_{{bar}}expanded_");
    markupLanguage.getTemplates().add(templateFoo);
    Template templateBar = new Template();
    templateBar.setName("bar");
    templateBar.setTemplateMarkup("+exp+");
    markupLanguage.getTemplates().add(templateBar);
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("one {{foo}} two");
    assertEquals("one _+exp+expanded_ two", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 33 with Template

use of org.eclipse.mylyn.wikitext.mediawiki.Template in project mylyn.docs by eclipse.

the class WikiTemplateResolverTest method testResolveTemplateDefault.

public void testResolveTemplateDefault() {
    Template template = resolver.resolveTemplate("bug");
    assertNotNull(template);
    assertEquals("bug", template.getName());
    assertEquals(BUG_TEMPLATE_CONTENT, template.getTemplateMarkup().trim());
}
Also used : Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Aggregations

Template (org.eclipse.mylyn.wikitext.mediawiki.Template)33 TemplateProcessor (org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor)27 HashSet (java.util.HashSet)2 TemplateResolver (org.eclipse.mylyn.wikitext.mediawiki.TemplateResolver)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1