Html Cleaner
Dependency :
compile ":html-cleaner:0.1"
Summary
whitelist based html cleaner based on jsoup
Installation
grails install-plugin html-cleaner
Description
Documentation userguideNote: The plugin has been developed to support 1.3.7> - It should work fine with the grails 2.x as well.*Read documentation for more details on how to define custom whitelists.
Defining custom whitelists
Plugin provides DSL to define whitelists in configuration.htmlcleaner {
whitelists = {
whitelist("sample") {
startwith "none"
allow "b", "p", "span"
}
whitelist("sample-with-anchor") {
startwith "sample"
allow("a") {
attributes "href"
enforce attribute:"rel", value:"nofollow"
}
} whitelist("basic-with-tables") {
startwith "basic"
allow "table", "tr", "td"
} }
}cleanHtml()
Plugin adds a dynamic method cleanHtml(String unsafe, String whitelistName) to all the controllers.class FooController {
def save = { String cleaned = cleanHtml(params.description, 'sample-with-anchor')
} }htmlCleaner bean
Plugin makes available a spring bean with name htmlCleaner that has a method cleanHtml() with same signature as the dynamic method available to controllers.<hc:cleanHtml> tag
<hc:cleanHtml unsafe="${domainInstance.description}" whitelist="sample" />