Class: PHPRB
- Inherits:
-
Object
show all
- Defined in:
- lib/web/phprb.rb,
lib/web/phprb.rb,
lib/web/phprb.rb,
lib/web/phprb.rb,
lib/web/phprb.rb
Overview
Defined Under Namespace
Modules: DefMethod, Util
Classes: Compiler
Constant Summary
collapse
- Revision =
'$Date: 2003/12/10 09:07:52 $'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(str, safe_level = nil, xml_mode = nil) ⇒ PHPRB
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# File 'lib/web/phprb.rb', line 238
def initialize(str, safe_level=nil, xml_mode=nil )
@safe_level = safe_level
compiler = PHPRB::Compiler.new(xml_mode)
compiler.put_cmd = "Web::write"
@src = compiler.compile(str)
@filename = nil
end
|
Instance Attribute Details
Returns the value of attribute filename.
274
275
276
|
# File 'lib/web/phprb.rb', line 274
def filename
@filename
end
|
Returns the value of attribute src.
273
274
275
|
# File 'lib/web/phprb.rb', line 273
def src
@src
end
|
Class Method Details
.load(script) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/web/phprb.rb', line 18
def PHPRB::load( script )
scriptname = script
script = if (File.exists? script)
File.open(scriptname,'r'){|f|f.read} || ""
else
scriptname = nil
script
end
script.gsub!( Web::SHEBANG_PATTERN, '' )
script = PHPRB.new(script, nil, Web::options[:xml] ).src
Web::Template.evaluate( scriptname, script )
end
|
11
12
13
|
# File 'lib/web/phprb.rb', line 11
def self.version
"erb.rb [2.0.4 #{PHPRB::Revision.split[1]}]"
end
|
Instance Method Details
#def_class(superklass = Object, methodname = 'result') ⇒ Object
302
303
304
305
306
|
# File 'lib/web/phprb.rb', line 302
def def_class(superklass=Object, methodname='result')
cls = Class.new(superklass)
def_method(cls, methodname)
cls
end
|
#def_method(mod, methodname, fname = '(PHPRB)') ⇒ Object
292
293
294
|
# File 'lib/web/phprb.rb', line 292
def def_method(mod, methodname, fname='(PHPRB)')
mod.module_eval("def #{methodname}\n" + self.src + "\nend\n", fname, 0)
end
|
#def_module(methodname = 'erb') ⇒ Object
296
297
298
299
300
|
# File 'lib/web/phprb.rb', line 296
def def_module(methodname='erb')
mod = Module.new
def_method(mod, methodname)
mod
end
|
#result(b = TOPLEVEL_BINDING) ⇒ Object
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/web/phprb.rb', line 280
def result(b=TOPLEVEL_BINDING)
if @safe_level
th = Thread.start {
$SAFE = @safe_level
eval(@src, b)
}
return th.value
else
return eval(@src, b, (@filename || '(erb)'), 1)
end
end
|
#run(b = TOPLEVEL_BINDING) ⇒ Object
276
277
278
|
# File 'lib/web/phprb.rb', line 276
def run(b=TOPLEVEL_BINDING)
print self.result(b)
end
|