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());
}
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());
}
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);
}
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();
}
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();
}
Aggregations