diff options
author | Yorhel <git@yorhel.nl> | 2017-12-16 13:20:49 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2017-12-16 13:20:49 +0100 |
commit | d77958674603a09c1d8a702dbbe876e10e2c51b6 (patch) | |
tree | 18c6a6baa3285827657fe2ff8b198b1274ba98b1 /lib/TUWF/XML.pm | |
parent | d185f54bdeaeb5af427732ffaec9e986920ee333 (diff) |
TUWF::XML: Add "mkclass" utility function
Diffstat (limited to 'lib/TUWF/XML.pm')
-rw-r--r-- | lib/TUWF/XML.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/TUWF/XML.pm b/lib/TUWF/XML.pm index 43208ae..77a3857 100644 --- a/lib/TUWF/XML.pm +++ b/lib/TUWF/XML.pm @@ -56,7 +56,7 @@ BEGIN { my @htmlexport = (qw| html Html lit txt tag end |); my @xmlexport = qw| xml lit txt tag end |; - @EXPORT_OK = uniq @htmlexport, @html5tags, @htmltags, @xmlexport, 'xml_escape', 'html_escape'; + @EXPORT_OK = uniq @htmlexport, @html5tags, @htmltags, @xmlexport, 'mkclass', 'xml_escape', 'html_escape'; %EXPORT_TAGS = ( html => [ @htmlexport, @htmltags ], html5 => [ @htmlexport, @html5tags ], @@ -96,6 +96,14 @@ sub new { }; +# Convenient function to generate a dynamic class attribute. +sub mkclass { + my %c = @_; + my $c = join ' ', grep $c{$_}, keys %c; + return $c ? (class => $c) : (); +} + + # XML escape (not a method) sub xml_escape { local $_ = shift; |