File: include.htm

package info (click to toggle)
libembperl-perl 2.5.0-17
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,632 kB
  • sloc: ansic: 21,387; perl: 14,497; javascript: 4,280; cpp: 467; xml: 49; makefile: 35; sh: 24
file content (219 lines) | stat: -rw-r--r-- 5,364 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

<html>
<head>
<title>Embperl Tests - Include other Embperl pages via Execute</title>
</head>

<h1>Embperl Tests - Include other Embperl pages via Execute</h1>

[- $optRawInput = 1 -]

[- $tst1 = '<P>Here is some text</P>' . "\n" ; -]


<H1> 1.) Include from memory</H1>

[-		       Execute ({input		=> \$tst1,
						 mtime      => 1,  
						 inputfile	=> 'Some text',
						 }) ;
-]

<H1> 2.) Include from memory with some Embperl code</H1>

[- Execute ({input		=> \('[- @ar = (a1, b2, c3) -' . ']<table><tr><td>[+$ar[$col]+]</td> </tr> </table> </P>' . "\n" ),
						 mtime      => 1,  
						 inputfile	=> 'table',
						 }) ;
-]

<H1> 3.) Include from memory with passing of variables</H1>


[- $MyPackage::Interface::Var = 'Some Var' ; -]

[- Execute ({input		=> \"<P>Transfer some vars [+ \$Var +] !</P>\n" ,
						 inputfile	=> 'Var',
						 mtime      => 1,
						 'package'  => 'MyPackage::Interface',
						 }) ;
-]

<H1> 4.) Change the variable, but not the code</H1>

[-

$MyPackage::Interface::Var = 'Do it again' ;

# code is the same, so give the same mtime and inputfile to avoid recompile
# Note you get problems is you change the code, but did not restart the server or
# change the value in mtime. So make sure if you change something also change mtime!

Execute ({input		=> \"<P>Transfer some vars [+ \$Var +] !</P>\n",
						 inputfile	=> 'Var2',
						 mtime      => 1,  
						 'package'  => 'MyPackage::Interface',
						 req_rec    => $req_rec}) ;
-]
<H1> 5a.) Use  method -> param to pass parameters</H1>


[-
Execute ({input		=> \"<P>Use method -> param to transfer some data ([+ do { \$p = shift -> component -> param -> param ;  \"\@\$p\" } +]) !</P>\n",
						 inputfile	=> 'Parammethod',
						 param      => [1, 2, 3, 4] }
						 ) ;
-]

<H1> 5.) Use \@param to pass parameters</H1>


[-
Execute ({input		=> \"<P>Use \@param to transfer some data ([+ \"\@param\" +]) !</P>\n",
						 inputfile	=> 'Param',
						 param      => [1, 2, 3, 4] }
						 ) ;
-]


<H1> 6.) Use \@param to pass parameters and return it</H1>

[- @p = ('vara', 'varb') ; -]

<H3> $p[0] is [+ $p[0] +] and $p[1] is [+ $p[1] +]<H3>

[-
Execute ({input		=> \('<P>Got data in @param ([+ "@param" +]) !</P>[- $param[0] = "newA" ; $param[1] = "newB" ; -' . ']<P>Change data in @param to ([+ "@param" +]) !</P>' . "\n"),
						 inputfile	=> 'Param & Return',
						 req_rec    => $req_rec,
						 param      => \@p }
						 ) ;
-]

<H3> $p[0] is now [+ $p[0] +] and $p[1] is now [+ $p[1] +] <H3>

<H1> 7.) Presetup \%fdat and \@ffld</H1>

[- 

%myfdat = ('test' => 'value',
              'fdat' => 'text') ;
              
@myffld = sort keys %myfdat ;             

Execute ({input		=> \('<P><table><tr><td>[+ $ffld[$row] +]</td><td>[+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]</td></tr></table></P>' . "\n") ,
						 inputfile	=> 'fdat & ffld',
						 req_rec    => $req_rec,
						 fdat  => \%myfdat,
						 ffld  => \@myffld}
						 ) ;

-]


<H1> 7a.) Presetup my \%fdat and my \@ffld</H1>

[- 

my %myfdat = ('test1' => 'value1',
              'fdat1' => 'text1') ;
              
my @myffld = sort keys %myfdat ;             

Execute ({input		=> \('<P><table><tr><td>[+ $ffld[$row] +]</td><td>[+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]</td></tr></table></P>' . "\n") ,
						 inputfile	=> 'fdat & ffld',
						 req_rec    => $req_rec,
						 fdat  => \%myfdat,
						 ffld  => \@myffld}
						 ) ;

-]

<H1> 7b.) Presetup \%fdat</H1>

[- 
%myfdat = ('test2' => 'value2',
              'fdat2' => 'text2') ;
              
#@myffld = sort keys %myfdat ;             
Execute ({input		=> \('<P><table><tr><td>[+ $ffld[$row] +]</td><td>[+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]</td></tr></table></P>' . "\n") ,
						 inputfile	=> 'fdat & ffld',
						 req_rec    => $req_rec,
						 fdat  => \%myfdat,}
						 ) ;

-]


<H1> 7c.) Presetup  \@ffld</H1>

[- 
%myfdat = ('test3' => 'value3',
              'fdat3' => 'text3') ;
              
@myffld = sort keys %myfdat ;             
Execute ({input		=> \('<P><table><tr><td>[+ $ffld[$row] +]</td><td>[+ do { local $^W = 0 ; $fdat{$ffld[$row]} } +]</td></tr></table></P> @ffld = [+ "@ffld" +]' . "\n") ,
						 inputfile	=> 'ffld',
						 req_rec    => $req_rec,
						 ffld  => \@myffld}
						 ) ;

-]


<H1> 8a.) Include a file</H1>

[- Execute ({inputfile => '../inc.htm', options => 0, input_escmode => 7, }) -]

<H1> 8b.) Include again the same file </H1>

[- Execute ({inputfile => '../inc.htm', options => 0, input_escmode => 7, }) -]

<H1> 9.) Include a file and return output in a scalar</H1>



[- Execute ({inputfile	=> '../inc.htm',
						 output     => \$out,
						 options => 0, input_escmode => 7, 
						 req_rec    => $req_rec}) ;
-]

<H3> [+ $out +] </H3>


<H1> 10.) Include inside a table</H1>

[- @a = ('m1', 'm2', 'm3') -]

<table>
    <tr>
	<td>
	    [+ $a[$row] +] : [- Execute ({inputfile => '../incsub.htm', req_rec => $req_rec, param => [$a[$row], 'main']}) -]
	</td>
    </tr>
</table>


<H1> 11.) Include a file with parameters</H1>

[- Execute ('../incparam.htm', 0, 'B', 'three', 'dddd', '555') -]

<H1> 12.) Include a file and write outputfile</H1>

[# - Execute ({inputfile	=> '../inc.htm',
			 outputfile     => "../../tmp/incout.htm",
						 }) ;
- #]

<H1> 12.) Done :-)</H1>

<br>


<p><hr>

<small>Embperl (c) 1997-2005 G.Richter</small>

</body>
</html>