bwu_bind_html 0.1.0 bwu_bind_html: ^0.1.0 copied to clipboard
Add HTML to the DOM using Polymer mustache binding
<bwu-bind-html> #
A Dart Polymer 1.0 element for binding text containing HTML
Usage #
The parent element has a property that provides some HTML string like:
@property String someHtml = '<div>some text</div>';
and in it's template this string can be bound like:
<bwu-bind-html html="[[someHtml]]"></bwu-bind-html>
Options #
Attributes #
The element can be configured using the following attributes
html
(typeString
) takes the HTML string to be added to the DOM (default''
)use-light-dom
(typebool
) adds the HTML to<bwu-bind-html>
s light DOM instead of the shady or shadow DOM (default) to make it easier to style the added HTML from the outside.validator
(typeNodeValidator
) allows to bind a validator that defines which HTML elements and attributes are allowed (defaultnew NodeValidatorBuilder()..allowTextElements();
).treeSanitizer
(typeNodeTreeSanitizer
) allows to bind a tree sanitizer (defaultnull
).
Application-wide default validator #
BwuBindHtml
allows to change the default validator
and treeSanitizer
which affects all instances of <bwu-bind-html>
with no
specific validator or treeSanitizer is bound to.
Change the defaults by assigning a validator
or treeSanitizer
instance to
the static fields BwuBindHtml.defaultValidator
or
BwuBindHtml.defaultTreeSanitizer
.
Note
For examples see the unit tests