SiteMeshExtendedPageParser - danielbodart/webfabric GitHub Wiki
A drop in replacement for the default HTMLPageParser that captures all DIVs with IDs found in the parsed document.
If you already have your own parser you can just add org.webfabric.sitemesh.v2.DivCapturingRule
via HTMLPageParser.addUserDefinedRules
If you use using SiteMesh 3 please add org.sitemesh.content.tagrules.html.DivExtractingTagRuleBundle
to your SiteMeshFilterBuilder (It's exactly the same just bundled with SiteMesh 3)
All DIVs with an ID will be available as page properties in the following format:
"div.{ID}" where {ID} is replace with the html ID
Add the following to /WEB-INF/sitemesh.xml
within the sitemesh tag:
<page-parsers>
<parser content-type="text/html" class="org.webfabric.sitemesh.v2.DivCapturingPageParser" />
</page-parsers>
<html>
<head><title>A title</title></head>
<body>
<div id="one">Some text</div>
<div id="two">Some more text</div>
</body></html>
The following page properties would be available after parsing the page:
Key | Value |
---|---|
title | A title |
div.one | Some text |
div.two | Some more text |