New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPostProcessorDialect implementation to minify/remove comments from output html #999
Comments
Here's a working demo Your error boils down to mixing APIs in an unsupported way. If you have a look at the documentation for PostProcessors you will see that it states:
a) b) The method
ITemplateHandler is an interface and does not have a constructor, thus the exception How can it be fixed?public class StripElementWhiteSpaceDialect implements IPostProcessorDialect {
Set<IPostProcessor> processors = new HashSet<>();
{
processors.add(new PostProcessor(TemplateMode.HTML, StripElementWhiteSpaceHandler.class, Integer.MAX_VALUE));
}
@Override
public int getDialectPostProcessorPrecedence() {
return 0;
}
@Override
public Set<IPostProcessor> getPostProcessors() {
return processors;
}
@Override
public String getName() {
return "Minifier";
}
public static class StripElementWhiteSpaceHandler extends AbstractTemplateHandler {
@Override
public void handleText(IText textNode) {
//update the text
super.handleText(...);
}
}
} |
@duoduobingbing thanks for the demo. But actually textNode.getText() is not the final complete processed output but rather chuncks. So doesnt fit what i was looking for. Thanks very much anyway. |
Following the discussion in #108
I am unable to find a proper example of a PostProcessor to achieve html minification or any other update on the html output using https://code.google.com/p/htmlcompressor/
There is a simpler Filter solution to achieve this but from this blog Filter as some performance downsides.
I believe this should be a built in feature but as rejected in previous issue.
Getting error with the following implementation, any help is welcome:
Getting error:
The text was updated successfully, but these errors were encountered: