blob: 92f3b64119aee90c9483acb70afec70c43eabd8d (
plain)
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
|
##
## $Release:$
## $Copyright$
##
require 'abstract'
module Erubis
##
## code generator, called by Converter module
##
module Generator
def self.supported_properties() # :nodoc:
return [
[:escapefunc, nil, "escape function name"],
]
end
attr_accessor :escapefunc
def init_generator(properties={})
@escapefunc = properties[:escapefunc]
end
## (abstract) escape text string
##
## ex.
## def escape_text(text)
## return text.dump
## # or return "'" + text.gsub(/['\\]/, '\\\\\&') + "'"
## end
def escape_text(text)
not_implemented
end
## return escaped expression code (ex. 'h(...)' or 'htmlspecialchars(...)')
def escaped_expr(code)
code.strip!
return "#{@escapefunc}(#{code})"
end
## (abstract) add @preamble to src
def add_preamble(src)
not_implemented
end
## (abstract) add text string to src
def add_text(src, text)
not_implemented
end
## (abstract) add statement code to src
def add_stmt(src, code)
not_implemented
end
## (abstract) add expression literal code to src. this is called by add_expr().
def add_expr_literal(src, code)
not_implemented
end
## (abstract) add escaped expression code to src. this is called by add_expr().
def add_expr_escaped(src, code)
not_implemented
end
## (abstract) add expression code to src for debug. this is called by add_expr().
def add_expr_debug(src, code)
not_implemented
end
## (abstract) add @postamble to src
def add_postamble(src)
not_implemented
end
end
end
|