Search in sources :

Example 1 with LagartoParser

use of jodd.lagarto.LagartoParser in project jodd by oblac.

the class StripHtmlTest method testStripHtml.

@Test
public void testStripHtml() {
    LagartoParser lagartoParser = new LagartoParser("<html>  <div   id='a'>   x \n\n\n </div>  </html>", false);
    StringBuilder out = new StringBuilder();
    StripHtmlTagAdapter stripHtmlTagAdapter = new StripHtmlTagAdapter(new TagWriter(out));
    lagartoParser.parse(stripHtmlTagAdapter);
    assertEquals("<html><div id=\"a\"> x </div></html>", out.toString());
}
Also used : TagWriter(jodd.lagarto.TagWriter) LagartoParser(jodd.lagarto.LagartoParser) Test(org.junit.Test)

Example 2 with LagartoParser

use of jodd.lagarto.LagartoParser in project jodd by oblac.

the class UrlRewriterTest method testUrlRewriter.

@Test
public void testUrlRewriter() {
    LagartoParser lagartoParser = new LagartoParser("<a href=\"http://jodd.org\">1</a><a href=\"page.html\">2</a>", false);
    StringBuilder out = new StringBuilder();
    UrlRewriterTagAdapter urlRewriterTagAdapter = new UrlRewriterTagAdapter(new TagWriter(out)) {

        @Override
        protected CharSequence rewriteUrl(CharSequence url) {
            String u = url.toString();
            if (u.startsWith("http")) {
                return url;
            }
            return "/ctx/" + url;
        }
    };
    lagartoParser.parse(urlRewriterTagAdapter);
    assertEquals("<a href=\"http://jodd.org\">1</a><a href=\"/ctx/page.html\">2</a>", out.toString());
}
Also used : TagWriter(jodd.lagarto.TagWriter) LagartoParser(jodd.lagarto.LagartoParser) Test(org.junit.Test)

Example 3 with LagartoParser

use of jodd.lagarto.LagartoParser in project jodd by oblac.

the class DecoraParser method parsePage.

/**
	 * Parses target page and extracts Decora regions for replacements.
	 */
protected void parsePage(char[] pageContent, DecoraTag[] decoraTags) {
    LagartoParser lagartoParser = new LagartoParser(pageContent, true);
    PageRegionExtractor writer = new PageRegionExtractor(decoraTags);
    lagartoParser.parse(writer);
}
Also used : LagartoParser(jodd.lagarto.LagartoParser)

Example 4 with LagartoParser

use of jodd.lagarto.LagartoParser in project jodd by oblac.

the class DecoraParser method parseDecorator.

/**
	 * Parses decorator file and collects {@link jodd.decora.parser.DecoraTag Decora tags}
	 * used in template. Returned Decora tags have start and end index set,
	 * but their region is not set.
	 */
protected DecoraTag[] parseDecorator(char[] decoraContent) {
    LagartoParser lagartoParser = new LagartoParser(decoraContent, true);
    lagartoParser.getConfig().setEnableRawTextModes(false);
    DecoratorTagVisitor visitor = new DecoratorTagVisitor();
    lagartoParser.parse(visitor);
    return visitor.getDecoraTags();
}
Also used : LagartoParser(jodd.lagarto.LagartoParser)

Example 5 with LagartoParser

use of jodd.lagarto.LagartoParser in project jodd by oblac.

the class FormTag method populateForm.

protected String populateForm(String formHtml, FormFieldResolver resolver) {
    LagartoParser lagartoParser = new LagartoParser(formHtml, true);
    StringBuilder result = new StringBuilder();
    lagartoParser.parse(new FormProcessorVisitor(result, resolver));
    return result.toString();
}
Also used : LagartoParser(jodd.lagarto.LagartoParser)

Aggregations

LagartoParser (jodd.lagarto.LagartoParser)7 TagWriter (jodd.lagarto.TagWriter)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 EmptyTagVisitor (jodd.lagarto.EmptyTagVisitor)1 LagartoException (jodd.lagarto.LagartoException)1 LagartoParserConfig (jodd.lagarto.LagartoParserConfig)1 Tag (jodd.lagarto.Tag)1 MutableInteger (jodd.mutable.MutableInteger)1