Search in sources :

Example 26 with TemplateProcessor

use of org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor 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 27 with TemplateProcessor

use of org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor 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 28 with TemplateProcessor

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

the class WikiTemplateResolverTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    TestWikiTemplateResolver resolverUnderTest = new TestWikiTemplateResolver();
    resolverUnderTest.setWikiBaseUrl("http://wiki.eclipse.org");
    Map<String, String> serverContent = new HashMap<>();
    serverContent.put("http://wiki.eclipse.org/index.php?title=Template%3Abug&action=raw", BUG_TEMPLATE_CONTENT);
    serverContent.put("http://wiki.eclipse.org/index.php?title=Test&action=raw", TEST_TEMPLATE_CONTENT);
    serverContent.put("http://wiki.eclipse.org/index.php?title=Other%3ATest&action=raw", OTHER_TEMPLATE_CONTENT);
    resolverUnderTest.setServerContent(serverContent);
    MediaWikiLanguage markupLanguage = new MediaWikiLanguage();
    markupLanguage.getTemplateProviders().add(resolverUnderTest);
    this.templateProcessor = new TemplateProcessor(markupLanguage);
    this.resolver = resolverUnderTest;
}
Also used : HashMap(java.util.HashMap) MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor)

Aggregations

TemplateProcessor (org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor)28 Template (org.eclipse.mylyn.wikitext.mediawiki.Template)27 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)1 TemplateResolver (org.eclipse.mylyn.wikitext.mediawiki.TemplateResolver)1