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