1HTML::RewriteAttributesU:s:eRresCoounrtcreisb(u3t)ed PerHlTMDLo:c:uRmeewnrtiatteiAotntributes::Resources(3)
2
3
4

NAME

6       HTML::RewriteAttributes::Resources - concise resource-link rewriting
7

SYNOPSIS

9           # writing some HTML email I see..
10           $html = HTML::RewriteAttributes::Resources->rewrite($html, sub {
11               my $uri = shift;
12               my $content = render_template($uri);
13               my $cid = generate_cid_from($content);
14               $mime->attach($cid => content);
15               return "cid:$cid";
16           });
17
18           # need to inline CSS too?
19           $html = HTML::RewriteAttributes::Resources->rewrite($html, sub {
20               # see above
21           },
22           inline_css => sub {
23               my $uri = shift;
24               return render_template($uri);
25           });
26
27           # need to inline CSS and follow @imports?
28           $html = HTML::RewriteAttributes::Resources->rewrite($html, sub {
29               # see above
30           },
31           inline_css => sub {
32               # see above
33           }, inline_imports => 1);
34

DESCRIPTION

36       "HTML::RewriteAttributes::Resources" is a special case of
37       HTML::RewriteAttributes for rewriting links to resources. This is to
38       facilitate generating, for example, HTML email in an extensible way.
39
40       We don't care about how to fetch resources and attach them to the MIME
41       object; that's your job. But you don't have to care about how to
42       rewrite the HTML.
43

METHODS

45   "new"
46       You don't need to call "new" explicitly - it's done in "rewrite". It
47       takes no arguments.
48
49   "rewrite" HTML, callback[, args] -> HTML
50       See the documentation of HTML::RewriteAttributes.
51
52       The callback receives as arguments the resource URI (the attribute
53       value), then, in a hash, "tag" and "attr".
54
55       Inlining CSS
56
57       "rewrite" can automatically inline CSS for you.
58
59       Passing "inline_css" will invoke that callback to inline "style" tags.
60       The callback receives as its argument the URI to a CSS file, and
61       expects as a return value the contents of that file, so that it may be
62       inlined. Returning "undef" prevents any sort of inlining.
63
64       Passing "inline_imports" (a boolean) will look at any inline CSS and
65       call the "inline_css" callback to inline that import.
66
67       This keeps track of what CSS has already been inlined, and won't inline
68       a particular CSS file more than once (to prevent import loops).
69

SEE ALSO

71       HTML::RewriteAttributes, HTML::Parser, Email::MIME::CreateHTML
72

AUTHOR

74       Shawn M Moore, "<sartak@bestpractical.com>"
75

LICENSE

77       Copyright 2008-2010 Best Practical Solutions, LLC.
78       HTML::RewriteAttributes::Resources is distributed under the same terms
79       as Perl itself.
80
81
82
83perl v5.32.1                      2021-01-H2T7ML::RewriteAttributes::Resources(3)
Impressum