erubis 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +150 -2
- data/LGPL +504 -0
- data/README.txt +14 -8
- data/benchmark/erubybench.rb +1 -1
- data/benchmark/erubybench.rhtml +3 -3
- data/bin/erubis +1 -1
- data/bin/notext +154 -0
- data/contrib/erubis +1036 -374
- data/contrib/inline-require +5 -3
- data/doc-api/classes/Erubis.html +43 -1
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/ArrayEnhancer.html +14 -14
- data/doc-api/classes/Erubis/Basic.html +112 -0
- data/doc-api/classes/Erubis/Basic/Converter.html +318 -0
- data/doc-api/classes/Erubis/Basic/Engine.html +130 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +14 -14
- data/doc-api/classes/Erubis/CGenerator.html +386 -0
- data/doc-api/classes/Erubis/Context.html +31 -32
- data/doc-api/classes/Erubis/Converter.html +231 -0
- data/doc-api/classes/Erubis/Ec.html +9 -283
- data/doc-api/classes/Erubis/Ejava.html +9 -274
- data/doc-api/classes/Erubis/Ejavascript.html +9 -298
- data/doc-api/classes/Erubis/Engine.html +68 -508
- data/doc-api/classes/Erubis/Eperl.html +9 -259
- data/doc-api/classes/Erubis/Ephp.html +9 -239
- data/doc-api/classes/Erubis/ErubisError.html +2 -2
- data/doc-api/classes/Erubis/Eruby.html +4 -187
- data/doc-api/classes/Erubis/EscapeEnhancer.html +9 -11
- data/doc-api/classes/Erubis/Escheme.html +9 -272
- data/doc-api/classes/Erubis/Evaluator.html +212 -0
- data/doc-api/classes/Erubis/Generator.html +410 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +16 -16
- data/doc-api/classes/Erubis/Helper.html +112 -0
- data/doc-api/classes/Erubis/Helper/CachedRailsTemplate.html +198 -0
- data/doc-api/classes/Erubis/Helper/RailsTemplate.html +366 -0
- data/doc-api/classes/Erubis/JavaGenerator.html +359 -0
- data/doc-api/classes/Erubis/JavascriptGenerator.html +381 -0
- data/doc-api/classes/Erubis/Main.html +27 -25
- data/doc-api/classes/Erubis/NoCodeEnhancer.html +249 -0
- data/doc-api/classes/Erubis/NoCodeEruby.html +120 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +8 -8
- data/doc-api/classes/Erubis/NotSupportedError.html +119 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +22 -304
- data/doc-api/classes/Erubis/OptimizedGenerator.html +439 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +7 -7
- data/doc-api/classes/Erubis/PI.html +124 -0
- data/doc-api/classes/Erubis/PI/Converter.html +318 -0
- data/doc-api/classes/Erubis/PI/Ec.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejava.html +166 -0
- data/doc-api/classes/Erubis/PI/Ejavascript.html +166 -0
- data/doc-api/classes/Erubis/PI/Engine.html +122 -0
- data/doc-api/classes/Erubis/PI/Eperl.html +166 -0
- data/doc-api/classes/Erubis/PI/Ephp.html +166 -0
- data/doc-api/classes/Erubis/PI/Eruby.html +155 -0
- data/doc-api/classes/Erubis/PI/Escheme.html +166 -0
- data/doc-api/classes/Erubis/PI/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +7 -7
- data/doc-api/classes/Erubis/PerlGenerator.html +344 -0
- data/doc-api/classes/Erubis/PhpGenerator.html +350 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +24 -24
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +35 -35
- data/doc-api/classes/Erubis/RubyEvaluator.html +190 -0
- data/doc-api/classes/Erubis/RubyGenerator.html +327 -0
- data/doc-api/classes/Erubis/SchemeGenerator.html +382 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +17 -13
- data/doc-api/classes/Erubis/StdoutEnhancer.html +14 -14
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +14 -14
- data/doc-api/classes/Erubis/TinyEruby.html +45 -40
- data/doc-api/classes/Erubis/XmlHelper.html +14 -14
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +27 -9
- data/doc-api/files/erubis/context_rb.html +107 -0
- data/doc-api/files/erubis/converter_rb.html +114 -0
- data/doc-api/files/erubis/engine/ec_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejava_rb.html +2 -2
- data/doc-api/files/erubis/engine/ejavascript_rb.html +2 -2
- data/doc-api/files/erubis/engine/enhanced_rb.html +2 -2
- data/doc-api/files/erubis/engine/eperl_rb.html +2 -2
- data/doc-api/files/erubis/engine/ephp_rb.html +2 -2
- data/doc-api/files/erubis/engine/eruby_rb.html +3 -2
- data/doc-api/files/erubis/engine/escheme_rb.html +2 -2
- data/doc-api/files/erubis/engine/optimized_rb.html +2 -2
- data/doc-api/files/erubis/engine_rb.html +6 -3
- data/doc-api/files/erubis/enhancer_rb.html +2 -9
- data/doc-api/files/erubis/error_rb.html +107 -0
- data/doc-api/files/erubis/evaluator_rb.html +115 -0
- data/doc-api/files/erubis/generator_rb.html +114 -0
- data/doc-api/files/erubis/helper/rails_rb.html +140 -0
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +2 -2
- data/doc-api/files/erubis/tiny_rb.html +2 -2
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +32 -0
- data/doc-api/fr_file_index.html +6 -0
- data/doc-api/fr_method_index.html +178 -136
- data/doc/users-guide.html +538 -199
- data/examples/{Makefile → basic/Makefile} +11 -11
- data/examples/basic/example.ec +42 -0
- data/examples/{example.ejava → basic/example.ejava} +5 -1
- data/examples/{example.ejavascript → basic/example.ejs} +0 -0
- data/examples/{example.eperl → basic/example.eperl} +2 -2
- data/examples/{example.ephp → basic/example.ephp} +0 -0
- data/examples/{example.eruby → basic/example.eruby} +0 -0
- data/examples/{example.escheme → basic/example.escheme} +0 -0
- data/examples/pi/Makefile +54 -0
- data/examples/pi/example.ec +42 -0
- data/examples/pi/example.ejava +45 -0
- data/examples/pi/example.ejs +16 -0
- data/examples/pi/example.eperl +16 -0
- data/examples/pi/example.ephp +17 -0
- data/examples/pi/example.eruby +15 -0
- data/examples/pi/example.escheme +26 -0
- data/lib/erubis.rb +15 -8
- data/lib/erubis/context.rb +54 -0
- data/lib/erubis/converter.rb +307 -0
- data/lib/erubis/engine.rb +57 -227
- data/lib/erubis/engine/ec.rb +31 -20
- data/lib/erubis/engine/ejava.rb +33 -21
- data/lib/erubis/engine/ejavascript.rb +30 -18
- data/lib/erubis/engine/enhanced.rb +7 -2
- data/lib/erubis/engine/eperl.rb +33 -19
- data/lib/erubis/engine/ephp.rb +32 -14
- data/lib/erubis/engine/eruby.rb +34 -7
- data/lib/erubis/engine/escheme.rb +34 -15
- data/lib/erubis/engine/optimized.rb +25 -11
- data/lib/erubis/enhancer.rb +53 -19
- data/lib/erubis/error.rb +24 -0
- data/lib/erubis/evaluator.rb +71 -0
- data/lib/erubis/generator.rb +83 -0
- data/lib/erubis/helper.rb +1 -1
- data/lib/erubis/helper/rails.rb +159 -0
- data/lib/erubis/local-setting.rb +1 -1
- data/lib/erubis/main.rb +87 -46
- data/lib/erubis/tiny.rb +81 -7
- data/test/assert-text-equal.rb +1 -1
- data/test/test-engines.rb +8 -9
- data/test/test-erubis.rb +196 -18
- data/test/{test-bin.rb → test-main.rb} +123 -21
- data/test/test-notext.rb +27 -0
- data/test/test.rb +5 -3
- data/test/testutil.rb +25 -36
- metadata +75 -13
- data/COPYING +0 -340
- data/examples/example.ec +0 -24
data/lib/erubis/engine/ec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 33 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -11,22 +11,21 @@ require 'erubis/enhancer'
|
|
|
11
11
|
module Erubis
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
class Ec < Engine
|
|
14
|
+
module CGenerator
|
|
15
|
+
include Generator
|
|
18
16
|
|
|
19
17
|
def self.supported_properties() # :nodoc:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
return [
|
|
19
|
+
[:indent, '', "indent spaces (ex. ' ')"],
|
|
20
|
+
[:out, 'stdout', "output file pointer name"],
|
|
21
|
+
]
|
|
24
22
|
end
|
|
25
23
|
|
|
26
|
-
def
|
|
24
|
+
def init_generator(properties={})
|
|
25
|
+
super
|
|
26
|
+
@escapefunc ||= "escape"
|
|
27
27
|
@indent = properties[:indent] || ''
|
|
28
28
|
@out = properties[:out] || 'stdout'
|
|
29
|
-
super
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
def add_preamble(src)
|
|
@@ -40,13 +39,7 @@ module Erubis
|
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
def escaped_expr(code)
|
|
43
|
-
@
|
|
44
|
-
code.strip!
|
|
45
|
-
if code =~ /\A(\".*?\")\s*,\s*(.*)/
|
|
46
|
-
return "#{$1}, #{@escape}(#{$2})"
|
|
47
|
-
else
|
|
48
|
-
return "#{@escape}(#{code})"
|
|
49
|
-
end
|
|
42
|
+
return "#{@escapefunc}(#{code.strip}, #{@out})"
|
|
50
43
|
end
|
|
51
44
|
|
|
52
45
|
def add_text(src, text)
|
|
@@ -74,7 +67,7 @@ module Erubis
|
|
|
74
67
|
|
|
75
68
|
def add_expr_escaped(src, code)
|
|
76
69
|
src << @indent if src.empty? || src[-1] == ?\n
|
|
77
|
-
src <<
|
|
70
|
+
src << ' ' << escaped_expr(code) << ';'
|
|
78
71
|
end
|
|
79
72
|
|
|
80
73
|
def add_expr_debug(src, code)
|
|
@@ -94,6 +87,14 @@ module Erubis
|
|
|
94
87
|
end
|
|
95
88
|
|
|
96
89
|
|
|
90
|
+
##
|
|
91
|
+
## engine for C
|
|
92
|
+
##
|
|
93
|
+
class Ec < Basic::Engine
|
|
94
|
+
include CGenerator
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
97
98
|
class EscapedEc < Ec
|
|
98
99
|
include EscapeEnhancer
|
|
99
100
|
end
|
|
@@ -103,5 +104,15 @@ module Erubis
|
|
|
103
104
|
# include EscapeEnhancer
|
|
104
105
|
#end
|
|
105
106
|
|
|
107
|
+
class PI::Ec < PI::Engine
|
|
108
|
+
include CGenerator
|
|
109
|
+
|
|
110
|
+
def init_converter(properties={})
|
|
111
|
+
@pi = 'c'
|
|
112
|
+
super(properties)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
end
|
|
116
|
+
|
|
106
117
|
|
|
107
118
|
end
|
data/lib/erubis/engine/ejava.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 31 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -11,24 +11,23 @@ require 'erubis/enhancer'
|
|
|
11
11
|
module Erubis
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
class Ejava < Engine
|
|
14
|
+
module JavaGenerator
|
|
15
|
+
include Generator
|
|
18
16
|
|
|
19
17
|
def self.supported_properties() # :nodoc:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
return [
|
|
19
|
+
[:indent, '', "indent spaces (ex. ' ')"],
|
|
20
|
+
[:buf, '_buf', "output buffer name"],
|
|
21
|
+
[:bufclass, 'StringBuffer', "output buffer class (ex. 'StringBuilder')"],
|
|
22
|
+
]
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
def
|
|
25
|
+
def init_generator(properties={})
|
|
26
|
+
super
|
|
27
|
+
@escapefunc ||= 'escape'
|
|
28
28
|
@indent = properties[:indent] || ''
|
|
29
29
|
@buf = properties[:buf] || '_buf'
|
|
30
30
|
@bufclass = properties[:bufclass] || 'StringBuffer'
|
|
31
|
-
super
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def add_preamble(src)
|
|
@@ -40,11 +39,6 @@ module Erubis
|
|
|
40
39
|
return text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] } || text
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
def escaped_expr(code)
|
|
44
|
-
@escape ||= 'escape'
|
|
45
|
-
return "#{@escape}(#{code.strip})"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
42
|
def add_text(src, text)
|
|
49
43
|
return if text.empty?
|
|
50
44
|
src << (src.empty? || src[-1] == ?\n ? @indent : ' ')
|
|
@@ -64,12 +58,12 @@ module Erubis
|
|
|
64
58
|
|
|
65
59
|
def add_expr_literal(src, code)
|
|
66
60
|
src << @indent if src.empty? || src[-1] == ?\n
|
|
67
|
-
|
|
61
|
+
code.strip!
|
|
62
|
+
src << " #{@buf}.append(#{code});"
|
|
68
63
|
end
|
|
69
64
|
|
|
70
65
|
def add_expr_escaped(src, code)
|
|
71
|
-
src
|
|
72
|
-
src << ' ' << @buf << '.append(' << escaped_expr(code) << ');'
|
|
66
|
+
add_expr_literal(src, escaped_expr(code))
|
|
73
67
|
end
|
|
74
68
|
|
|
75
69
|
def add_expr_debug(src, code)
|
|
@@ -81,11 +75,20 @@ module Erubis
|
|
|
81
75
|
def add_postamble(src)
|
|
82
76
|
src << "\n" if src[-1] == ?;
|
|
83
77
|
src << @indent << "return " << @buf << ".toString();\n"
|
|
78
|
+
#src << @indent << "System.out.print(" << @buf << ".toString());\n"
|
|
84
79
|
end
|
|
85
80
|
|
|
86
81
|
end
|
|
87
82
|
|
|
88
83
|
|
|
84
|
+
##
|
|
85
|
+
## engine for Java
|
|
86
|
+
##
|
|
87
|
+
class Ejava < Basic::Engine
|
|
88
|
+
include JavaGenerator
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
89
92
|
class EscapedEjava < Ejava
|
|
90
93
|
include EscapeEnhancer
|
|
91
94
|
end
|
|
@@ -95,5 +98,14 @@ module Erubis
|
|
|
95
98
|
# include EscapeEnhancer
|
|
96
99
|
#end
|
|
97
100
|
|
|
101
|
+
class PI::Ejava < PI::Engine
|
|
102
|
+
include JavaGenerator
|
|
103
|
+
|
|
104
|
+
def init_converter(properties={})
|
|
105
|
+
@pi = 'java'
|
|
106
|
+
super(properties)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
98
110
|
|
|
99
111
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 31 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -11,23 +11,21 @@ require 'erubis/enhancer'
|
|
|
11
11
|
module Erubis
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
class Ejavascript < Engine
|
|
14
|
+
module JavascriptGenerator
|
|
15
|
+
include Generator
|
|
18
16
|
|
|
19
17
|
def self.supported_properties() # :nodoc:
|
|
20
|
-
list =
|
|
18
|
+
list = []
|
|
21
19
|
#list << [:indent, '', "indent spaces (ex. ' ')"]
|
|
22
20
|
#list << [:buf, '_buf', "output buffer name"]
|
|
23
21
|
return list
|
|
24
22
|
end
|
|
25
23
|
|
|
26
|
-
def
|
|
24
|
+
def init_generator(properties={})
|
|
25
|
+
super
|
|
26
|
+
@escapefunc ||= 'escape'
|
|
27
27
|
@indent = properties[:indent] || ''
|
|
28
28
|
@buf = properties[:out] || '_buf'
|
|
29
|
-
#@bufclass = properties[:outclass] || 'StringBuffer'
|
|
30
|
-
super
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
def add_preamble(src)
|
|
@@ -39,11 +37,6 @@ module Erubis
|
|
|
39
37
|
return text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] } || text
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
def escaped_expr(code)
|
|
43
|
-
@escape ||= 'escape'
|
|
44
|
-
return "#{@escape}(#{code.strip})"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
40
|
def add_indent(src, indent)
|
|
48
41
|
src << (src.empty? || src[-1] == ?\n ? indent : ' ')
|
|
49
42
|
end
|
|
@@ -67,12 +60,12 @@ module Erubis
|
|
|
67
60
|
|
|
68
61
|
def add_expr_literal(src, code)
|
|
69
62
|
add_indent(src, @indent)
|
|
70
|
-
|
|
63
|
+
code.strip!
|
|
64
|
+
src << "#{@buf}.push(#{code});"
|
|
71
65
|
end
|
|
72
66
|
|
|
73
67
|
def add_expr_escaped(src, code)
|
|
74
|
-
|
|
75
|
-
src << @buf << '.push(' << escaped_expr(code) << ');'
|
|
68
|
+
add_expr_literal(src, escaped_expr(code))
|
|
76
69
|
end
|
|
77
70
|
|
|
78
71
|
def add_expr_debug(src, code)
|
|
@@ -89,6 +82,14 @@ module Erubis
|
|
|
89
82
|
end
|
|
90
83
|
|
|
91
84
|
|
|
85
|
+
##
|
|
86
|
+
## engine for JavaScript
|
|
87
|
+
##
|
|
88
|
+
class Ejavascript < Basic::Engine
|
|
89
|
+
include JavascriptGenerator
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
92
93
|
class EscapedEjavascript < Ejavascript
|
|
93
94
|
include EscapeEnhancer
|
|
94
95
|
end
|
|
@@ -99,4 +100,15 @@ module Erubis
|
|
|
99
100
|
#end
|
|
100
101
|
|
|
101
102
|
|
|
103
|
+
class PI::Ejavascript < PI::Engine
|
|
104
|
+
include JavascriptGenerator
|
|
105
|
+
|
|
106
|
+
def init_converter(properties={})
|
|
107
|
+
@pi = 'js'
|
|
108
|
+
super(properties)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
102
114
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 27 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -67,6 +67,11 @@ module Erubis
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
|
|
70
|
+
class NoCodeEruby < Eruby
|
|
71
|
+
include NoCodeEnhancer
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
70
75
|
class SimplifiedEruby < Eruby
|
|
71
76
|
include SimplifyEnhancer
|
|
72
77
|
end
|
data/lib/erubis/engine/eperl.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 40 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -11,24 +11,23 @@ require 'erubis/enhancer'
|
|
|
11
11
|
module Erubis
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
class Eperl < Engine
|
|
14
|
+
module PerlGenerator
|
|
15
|
+
include Generator
|
|
18
16
|
|
|
19
17
|
def self.supported_properties() # :nodoc:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
return [
|
|
19
|
+
[:func, 'print', "function name"],
|
|
20
|
+
]
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
def
|
|
26
|
-
@func = properties[:func] || 'print'
|
|
23
|
+
def init_generator(properties={})
|
|
27
24
|
super
|
|
25
|
+
@escapefunc ||= 'encode_entities'
|
|
26
|
+
@func = properties[:func] || 'print'
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
def add_preamble(src)
|
|
31
|
-
|
|
30
|
+
src << "use HTML::Entities; ";
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def escape_text(text)
|
|
@@ -39,17 +38,13 @@ module Erubis
|
|
|
39
38
|
src << @func << "('" << escape_text(text) << "'); " unless text.empty?
|
|
40
39
|
end
|
|
41
40
|
|
|
42
|
-
def escaped_expr(code)
|
|
43
|
-
@escape ||= 'escape'
|
|
44
|
-
return "escape(#{code.strip})"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
41
|
def add_expr_literal(src, code)
|
|
48
|
-
|
|
42
|
+
code.strip!
|
|
43
|
+
src << @func << "(" << code << "); "
|
|
49
44
|
end
|
|
50
45
|
|
|
51
46
|
def add_expr_escaped(src, code)
|
|
52
|
-
src
|
|
47
|
+
add_expr_literal(src, escaped_expr(code))
|
|
53
48
|
end
|
|
54
49
|
|
|
55
50
|
def add_expr_debug(src, code)
|
|
@@ -69,6 +64,14 @@ module Erubis
|
|
|
69
64
|
end
|
|
70
65
|
|
|
71
66
|
|
|
67
|
+
##
|
|
68
|
+
## engine for Perl
|
|
69
|
+
##
|
|
70
|
+
class Eperl < Basic::Engine
|
|
71
|
+
include PerlGenerator
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
72
75
|
class EscapedEperl < Eperl
|
|
73
76
|
include EscapeEnhancer
|
|
74
77
|
end
|
|
@@ -79,4 +82,15 @@ module Erubis
|
|
|
79
82
|
#end
|
|
80
83
|
|
|
81
84
|
|
|
85
|
+
class PI::Eperl < PI::Engine
|
|
86
|
+
include PerlGenerator
|
|
87
|
+
|
|
88
|
+
def init_converter(properties={})
|
|
89
|
+
@pi = 'perl'
|
|
90
|
+
super(properties)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
82
96
|
end
|
data/lib/erubis/engine/ephp.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
|
-
## $Rev:
|
|
3
|
-
## $Release: 2.0
|
|
2
|
+
## $Rev: 31 $
|
|
3
|
+
## $Release: 2.1.0 $
|
|
4
4
|
## copyright(c) 2006 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
|
|
@@ -11,13 +11,16 @@ require 'erubis/enhancer'
|
|
|
11
11
|
module Erubis
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
class Ephp < Engine
|
|
14
|
+
module PhpGenerator
|
|
15
|
+
include Generator
|
|
18
16
|
|
|
19
17
|
def self.supported_properties() # :nodoc:
|
|
20
|
-
return
|
|
18
|
+
return []
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def init_generator(properties={})
|
|
22
|
+
super
|
|
23
|
+
@escapefunc ||= 'htmlspecialchars'
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
def add_preamble(src)
|
|
@@ -32,17 +35,13 @@ module Erubis
|
|
|
32
35
|
src << escape_text(text)
|
|
33
36
|
end
|
|
34
37
|
|
|
35
|
-
def escaped_expr(code)
|
|
36
|
-
@escape ||= 'htmlspecialchars'
|
|
37
|
-
return "#{@escape}(#{code.strip})"
|
|
38
|
-
end
|
|
39
|
-
|
|
40
38
|
def add_expr_literal(src, code)
|
|
41
|
-
|
|
39
|
+
code.strip!
|
|
40
|
+
src << "<?php echo #{code}; ?>"
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def add_expr_escaped(src, code)
|
|
45
|
-
src
|
|
44
|
+
add_expr_literal(src, escaped_expr(code))
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
def add_expr_debug(src, code)
|
|
@@ -69,6 +68,14 @@ module Erubis
|
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
|
|
71
|
+
##
|
|
72
|
+
## engine for PHP
|
|
73
|
+
##
|
|
74
|
+
class Ephp < Basic::Engine
|
|
75
|
+
include PhpGenerator
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
72
79
|
class EscapedEphp < Ephp
|
|
73
80
|
include EscapeEnhancer
|
|
74
81
|
end
|
|
@@ -79,4 +86,15 @@ module Erubis
|
|
|
79
86
|
#end
|
|
80
87
|
|
|
81
88
|
|
|
89
|
+
class PI::Ephp < PI::Engine
|
|
90
|
+
include PhpGenerator
|
|
91
|
+
|
|
92
|
+
def init_converter(properties={})
|
|
93
|
+
@pi = 'php'
|
|
94
|
+
super(properties)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
82
100
|
end
|