Search in sources :

Example 26 with Template

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

the class TemplateProcessorTest method testBasicTemplateIncludeonly.

public void testBasicTemplateIncludeonly() {
    Template template = new Template();
    template.setName("test");
    template.setTemplateMarkup("foo bar baz\n<includeonly>_expanded_</includeonly>");
    markupLanguage.getTemplates().add(template);
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("one {{test}} two");
    assertEquals("one _expanded_ two", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 27 with Template

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

the class TemplateProcessorTest method testBasicTemplateExcluded.

public void testBasicTemplateExcluded() {
    Template template = new Template();
    template.setName("test");
    template.setTemplateMarkup("_expanded_");
    markupLanguage.getTemplates().add(template);
    markupLanguage.setTemplateExcludes("boo, baz, test");
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("one {{test}} two");
    assertEquals("one  two", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 28 with Template

use of org.eclipse.mylyn.wikitext.mediawiki.Template 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());
    }
}
Also used : TemplateResolver(org.eclipse.mylyn.wikitext.mediawiki.TemplateResolver) TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) HashSet(java.util.HashSet) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 29 with Template

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

the class TemplateProcessorTest method testBasicTemplatePositionalParameter.

public void testBasicTemplatePositionalParameter() {
    Template template = new Template();
    template.setName("test");
    template.setTemplateMarkup("_expanded{{{1}}}and{{{2}}}and{{{1}}}_");
    markupLanguage.getTemplates().add(template);
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("one {{test|one|two}} two");
    assertEquals("one _expandedoneandtwoandone_ two", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) Template(org.eclipse.mylyn.wikitext.mediawiki.Template)

Example 30 with Template

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

the class TemplateProcessorTest method testBasicTemplateNamedParameterMissingValue.

public void testBasicTemplateNamedParameterMissingValue() {
    Template template = new Template();
    template.setName("test");
    template.setTemplateMarkup("_expanded{{{message}}}_");
    markupLanguage.getTemplates().add(template);
    TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
    String markup = templateProcessor.processTemplates("one {{test}} two");
    assertEquals("one _expanded_ two", markup);
}
Also used : TemplateProcessor(org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor) 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