1Wiki::Toolkit::FormatteUrs:e:rMuClotnitprlieb(u3t)ed PerWlikDio:c:uTmoeonltkaitti:o:nFormatter::Multiple(3)
2
3
4
6 Wiki::Toolkit::Formatter::Multiple - Allows a Wiki::Toolkit wiki to use
7 more than one formatter.
8
10 A "dummy" formatter for Wiki::Toolkit. Passes methods through to other
11 Wiki::Toolkit formatters, depending on supplied metadata.
12
14 use Wiki::Toolkit::Formatter::Multiple;
15 use Wiki::Toolkit::Formatter::Pod;
16 use Wiki::Toolkit::Formatter::UseMod;
17
18 my $pod_fmtr = Wiki::Toolkit::Formatter::Pod->new(
19 node_prefix => "wiki.cgi?node=",
20 );
21
22 my $usemod_fmtr = Wiki::Toolkit::Formatter::UseMod->new(
23 node_prefix => "wiki.cgi?node=",
24 extended_links => 1,
25 allowed_tags => [ qw( p b i div br ) ],
26 );
27
28 my $formatter = Wiki::Toolkit::Formatter::Multiple->new(
29 documentation => $pod_fmtr,
30 discussion => $usemod_fmtr,
31 _DEFAULT => $usemod_fmtr,
32 );
33
34 my $wiki = Wiki::Toolkit->new( store => ...,
35 formatter => $formatter );
36 my $output = $wiki->format( "This is some discussion.",
37 { formatter => "discussion" } );
38
40 new
41 my $formatter = Wiki::Toolkit::Formatter::Multiple->new(
42 label_1 => Formatter1->new( ... ),
43 label_2 => Formatter2->new( ... ),
44 _DEFAULT => Wiki::Toolkit::Formatter::Default->new,
45 );
46
47 You may supply as many formatter objects as you wish. They don't
48 have to be of different classes; you may just wish to, for example,
49 permit different HTML tags to be used on different types of pages.
50
51 The "labels" supplied as the keys of the parameter hash should be
52 unique. When you write a node, you should store a key-value pair
53 in its metadata where the key is "formatter" and the value is the
54 label of the formatter that should be used to render that node.
55
56 The "_DEFAULT" label is special - it defines the formatter that
57 will be used for any node that does not have a "formatter" stored
58 in its metadata. The "_DEFAULT" formatter, if not supplied to
59 "->new", will default to the very basic
60 Wiki::Toolkit::Formatter::Default.
61
62 format( $raw, \%metadata )
63 my $output = $formatter->format( "Here is some text.", undef,
64 { formatter => "discussion" } );
65
66 Uses the value of "formatter" given in the metadata to decide which
67 of the formatter objects passed on instantiation to use, then uses
68 it to format the provided rawwikitext.
69
70 The "undef" second element of the parameter array in the example is
71 there because when this is called from a Wiki::Toolkit object, the
72 wiki object passes itself in as the second parameter.
73
74 find_internal_links( $raw, $metadata )
75
77 Wiki::Toolkit
78
80 Kake Pugh <kake@earth.li>
81
83 Bug reports, questions and feature requests should go to
84 cgi-wiki-dev@earth.li
85
87 Copyright (C) 2003-4 Kake Pugh. All Rights Reserved.
88
89 This module is free software; you can redistribute it and/or modify it
90 under the same terms as Perl itself.
91
92
93
94perl v5.28.1 2016-12-W1i6ki::Toolkit::Formatter::Multiple(3)