uHTML/uTags.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 6 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 78 CC 11 SCAR 29.1
CC
11
Cov
0%
Test_uHTML_Tag
30.0
Test_uHTML_Var
30.0
List_uHTML_Tags
6.0
CRAP 18.4
1  
2 #
3 # Author: Roland Mosler - Roland@Place.Ug
4 #
5 # Das ist eine uHTML-Bibliothek von Place.Ug
6 # Es ist erlaubt dieses Paket unter der aktuellen GNU GPL zu nutzen
7 # Bei Weiterentwicklungen ist die Ursprungsbibliothek zu nennen
8 #
9 # Fehler und Verbesserungen bitte an B<uHTML>@Place.Ug
10 #
11 # This is a uHTML library from Place.Ug
12 # It is allowed to use this library under the actual GNU GPL
13 # The name of this library is to be named in all derivations
14 #
15 # Please report errors to uHTML@Place.Ug
16 #
17 # Roland Mosler, Place.Ug
18 #
19  
20  
21  
22  
23 use strict ;
24 use uHTML ;
25 use uHTML::ListFuncs( 'uniq' ) ;
26  
27 use version ; our $VERSION = "1.0" ;
28  
29  
30 sub List_uHTML_Tags( $ )
31 {
32 my( $Node,$Par,$Var,$Head,$Join,$Tail ) = @_ ;
33  
34 unless( $Par )
35 {
36 $Join = $Node->codeAttr( 'join' ) ;
37 $Head = $Node->codeAttr( 'head' ) ;
38 $Tail = $Node->codeAttr( 'tail' ) ;
39 }
40  
41 return $Head.join( $Join,uniq sort uHTML::tags() ).$Tail ;
42 }
43  
44  
45  
46 sub List_uHTML_Vars( $ )
47 {
48 my( $Node,$Par,$Var,$Head,$Join,$Tail ) = @_ ;
49  
50 unless( $Par )
51 {
52 $Join = $Node->codeAttr( 'join' ) ;
53 $Head = $Node->codeAttr( 'head' ) ;
54 $Tail = $Node->codeAttr( 'tail' ) ;
55 }
56  
57 return $Head.join( $Join,sort uHTML::vars() ).$Tail ;
58 }
59  
60  
61 sub Test_uHTML_Tag
62 {
63 my( $Node,$Par,$Var,$Name,$Ret ) = @_ ;
64 $Name= $Node->attr( 'name' ) and $Ret = $Node->attr( 'msg' ) unless $Par ;
65 return '' unless $Name ;
66 $Ret = 1 unless $Ret ;
67 return( uHTML::testTag( $Name ) ? $Ret : '' ) ;
68 }
69  
70 sub Test_uHTML_Var
71 {
72 my( $Node,$Par,$Var,$Name,$Ret ) = @_ ;
73 $Name= $Node->attr( 'name' ) and $Ret = $Node->attr( 'msg' ) unless $Par ;
74 return '' unless $Name ;
75 $Ret = 1 unless $Ret ;
76 return( uHTML::testVar( $Name ) ? $Ret : '' ) ;
77 }
78  
79  
80 uHTML::register( 'uhtmlTL',\&List_uHTML_Tags ) ;
81 uHTML::register( 'ListTags',\&List_uHTML_Tags ) ;
82 uHTML::register( 'ListVars',\&List_uHTML_Vars ) ;
83 uHTML::register( 'TestTag',\&Test_uHTML_Tag ) ;
84 uHTML::register( 'TestVar',\&Test_uHTML_Var ) ;
85  
86  
87  
88 ######################################
89 ######################################
90  
91 =pod
92  
93 =encoding UTF-8
94  
95 =head1 NAME
96  
97 =over 2
98  
99 =item B<uHTML::uTags> - Testing B<uHTML> tags and functions for existence
100  
101 =back
102  
103 =head1 VERSION
104  
105 Version 1.0
106  
107 =head1 DESCRIPTION
108  
109 The library B<uHTML::uTags> provides tags and functions to check the existence of an
110 particular B<uHTML>-tag or function. This library is thought mainly as a debug tool
111 for the designer and rarely of practical use in working websites.
112  
113 Requirements
114  
115 The B<uHTML::uTags> library requires the B<uHTML>::listfuncs library and the main B<uHTML> library.
116  
117  
118  
119 B< >
120  
121 =head1 B<uHTML> tags provided by the uHTML::uTags library
122  
123 B< >
124  
125 =head2 ListTags
126  
127 =head3 Overview
128  
129 The ListTags tag lists all B<uHTML> tags with associated program code.
130  
131 =head3 Attributes
132  
133 =head4 head="text"
134  
135 The attribute head defines the text preceding the tag list.
136  
137 =head4 join="text"
138  
139 The attribute join defines the text between two consecutive tag names.
140  
141 =head4 tail="text"
142  
143 The attribute tail defines the text following the tag list.
144  
145 =head3 Example
146  
147 <ListTags head="Known tags: " join=", " tail=".">
148  
149 =head2 ListVars
150  
151 =head3 Overview
152  
153 The ListVars tag lists all known B<uHTML> attribute variables.
154  
155 =head3 Attributes
156  
157 =head4 head="text"
158  
159 The attribute head defines the text preceding the variables list.
160  
161 =head4 join="text"
162  
163 The attribute join defines the text between two consecutive variables names.
164  
165 =head4 tail="text"
166  
167 The attribute tail defines the text following the variables list.
168  
169 =head3 Example
170  
171 <ListVars head="Known variables: " join=", " tail=".">
172  
173 =head2 TestTag
174  
175 =head3 Overview
176  
177 The TestTag tag tests if a particular B<uHTML> tag has program code associated with it.
178  
179 =head3 Attributes
180  
181 =head4 name="text"
182  
183 Name of the tested tag.
184  
185 =head4 msg="text"
186  
187 Message displayed in case the tag name has code connected to it.
188  
189 =head3 Example
190  
191 <TestTag name="if" msg="<b>if</b> is defined.">
192  
193 =head2 TestVar
194  
195 =head3 Overview
196  
197 The TestVar tag tests if a particular B<uHTML> attribute variable is known.
198  
199 =head3 Attributes
200  
201 =head4 name="text"
202  
203 Name of the tested variable.
204  
205 =head4 msg="text"
206  
207 Message displayed in case the variable name is known.
208  
209 =head3 Example
210  
211 <TestVar name="RepeatValue" msg="<b>RepeatValue</b> is defined as variable.">
212  
213  
214 B< >
215  
216 B< >
217  
218 =head1 Attribute variables and functions provided by the uHTML::uTags library
219  
220 B< >
221  
222 =head2 $ListTags(head,join,tail)
223  
224 =head3 Overview
225  
226 The ListTags function returns a list of all B<uHTML> tags associated with program code.
227  
228 =head3 Parameters
229  
230 =head4 head
231  
232 The parameter head defines the text preceding the tag list.
233  
234 =head4 join
235  
236 The parameter join defines the text between two consecutive tag names.
237  
238 =head4 tail
239  
240 The parameter tail defines the text following the tag list.
241  
242 =head3 Example
243  
244 <uList elements="$ListTags('',',','')">
245 ...
246 </uList>
247  
248 =head2 $ListVars(head,join,tail)
249  
250 =head3 Overview
251  
252 The ListVars function returns a list of all known B<uHTML> attribute variables.
253  
254 =head3 Parameters
255  
256 =head4 head
257  
258 The parameter head defines the text preceding the variables list.
259  
260 =head4 join
261  
262 The parameter join defines the text between two consecutive variables names.
263  
264 =head4 tail
265  
266 The parameter tail defines the text following the variables list.
267  
268 =head3 Example
269  
270 <uList elements="$ListVars('',',','')">
271 ...
272 </uList>
273  
274 =head2 $TestTag(name,ret)
275  
276 =head3 Overview
277  
278 The $TestTag function tests if a particular B<uHTML> tag has program code associated with it.
279  
280 =head3 Parameters
281  
282 =head4 name
283  
284 Name of the tested tag.
285  
286 =head4 msg
287  
288 Value returned in case the tag name has code connected to it.
289  
290 =head3 Example
291  
292 <if cond="$TestTag(include,1)">Tag "include" is defined.</if>
293  
294 =head2 $TestVar(name,ret)
295  
296 =head3 Overview
297  
298 The $TestVar function tests if a particular B<uHTML> attribute variable is known.
299  
300 =head3 Parameters
301  
302 =head4 name
303  
304 Name of the tested attribute variable.
305  
306 =head4 ret
307  
308 Value returned in case the attribute variable name is known.
309  
310 =head3 Example
311  
312 <if cond="$TestVar(RepeatValue,1)">RepeatValue is defined.</if>
313  
314  
315 =head1 SEE ALSO
316  
317 perl(1), uHTML, uHTML::ListFuncs, http://www.uhtml.de/en/doc/uTags.uhtml
318  
319  
320  
321 =head1 AUTHOR
322  
323 Roland Mosler (Roland.Mosler@Place.Ug)
324  
325 =head1 COPYRIGHT
326  
327 Copyright 2009 Roland Mosler. All rights reserved.
328  
329 This library is free software; you can redistribute it and/or
330 modify it under the same terms as Perl itself.
331