erubis 2.4.1 → 2.5.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/{CHANGES → CHANGES.txt} +59 -3
- data/MIT-LICENSE +1 -1
- data/README.txt +5 -5
- data/benchmark/bench.rb +2 -2
- data/bin/erubis +2 -2
- data/contrib/erubis +46 -46
- data/contrib/inline-require +2 -2
- data/doc-api/classes/Erubis.html +5 -1
- data/doc-api/classes/Erubis/ArrayEnhancer.html +12 -12
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +12 -12
- data/doc-api/classes/Erubis/CGenerator.html +60 -60
- data/doc-api/classes/Erubis/Context.html +42 -42
- data/doc-api/classes/Erubis/DeleteIndentEnhancer.html +6 -6
- data/doc-api/classes/Erubis/Engine.html +30 -30
- data/doc-api/classes/Erubis/ErboutEnhancer.html +12 -12
- data/doc-api/classes/Erubis/EscapeEnhancer.html +6 -6
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +12 -12
- data/doc-api/classes/Erubis/Helpers.html +6 -1
- data/doc-api/classes/Erubis/Helpers/RailsFormHelper.html +762 -0
- data/doc-api/classes/Erubis/Helpers/RailsHelper.html +12 -18
- data/doc-api/classes/Erubis/Helpers/RailsHelper/PreprocessingEruby.html +2 -2
- data/doc-api/classes/Erubis/JavaGenerator.html +54 -54
- data/doc-api/classes/Erubis/JavascriptGenerator.html +60 -60
- data/doc-api/classes/Erubis/Main.html +19 -19
- data/doc-api/classes/Erubis/NoTextEnhancer.html +6 -6
- data/doc-api/classes/Erubis/OptimizedEruby.html +6 -6
- data/doc-api/classes/Erubis/OptimizedGenerator.html +72 -72
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +6 -6
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +6 -6
- data/doc-api/classes/Erubis/PhpGenerator.html +54 -54
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +20 -20
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +30 -30
- data/doc-api/classes/Erubis/RubyEvaluator.html +18 -18
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +12 -12
- data/doc-api/classes/Erubis/TinyEruby.html +24 -24
- data/doc-api/classes/Erubis/XmlHelper.html +30 -30
- data/doc-api/created.rid +1 -1
- data/doc-api/files/README_txt.html +6 -7
- data/doc-api/files/erubis/context_rb.html +1 -1
- data/doc-api/files/erubis/converter_rb.html +1 -1
- data/doc-api/files/erubis/engine/ec_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejava_rb.html +1 -1
- data/doc-api/files/erubis/engine/ejavascript_rb.html +1 -1
- data/doc-api/files/erubis/engine/enhanced_rb.html +1 -1
- data/doc-api/files/erubis/engine/eperl_rb.html +1 -1
- data/doc-api/files/erubis/engine/ephp_rb.html +1 -1
- data/doc-api/files/erubis/engine/eruby_rb.html +1 -1
- data/doc-api/files/erubis/engine/escheme_rb.html +1 -1
- data/doc-api/files/erubis/engine/optimized_rb.html +1 -1
- data/doc-api/files/erubis/engine_rb.html +1 -1
- data/doc-api/files/erubis/enhancer_rb.html +1 -1
- data/doc-api/files/erubis/error_rb.html +1 -1
- data/doc-api/files/erubis/evaluator_rb.html +1 -1
- data/doc-api/files/erubis/generator_rb.html +1 -1
- data/doc-api/files/erubis/helper_rb.html +1 -1
- data/doc-api/files/erubis/helpers/rails_form_helper_rb.html +107 -0
- data/doc-api/files/erubis/helpers/rails_helper_rb.html +2 -2
- data/doc-api/files/erubis/local-setting_rb.html +1 -1
- data/doc-api/files/erubis/main_rb.html +1 -1
- data/doc-api/files/erubis/tiny_rb.html +1 -1
- data/doc-api/files/erubis_rb.html +2 -2
- data/doc-api/fr_class_index.html +1 -0
- data/doc-api/fr_file_index.html +1 -0
- data/doc-api/fr_method_index.html +162 -138
- data/doc/users-guide.html +157 -62
- data/lib/erubis.rb +4 -4
- data/lib/erubis/context.rb +2 -2
- data/lib/erubis/converter.rb +2 -2
- data/lib/erubis/engine.rb +2 -2
- data/lib/erubis/engine/ec.rb +2 -2
- data/lib/erubis/engine/ejava.rb +2 -2
- data/lib/erubis/engine/ejavascript.rb +2 -2
- data/lib/erubis/engine/enhanced.rb +2 -2
- data/lib/erubis/engine/eperl.rb +2 -2
- data/lib/erubis/engine/ephp.rb +2 -2
- data/lib/erubis/engine/eruby.rb +2 -2
- data/lib/erubis/engine/escheme.rb +2 -2
- data/lib/erubis/engine/optimized.rb +2 -2
- data/lib/erubis/enhancer.rb +2 -2
- data/lib/erubis/error.rb +2 -2
- data/lib/erubis/evaluator.rb +2 -2
- data/lib/erubis/generator.rb +2 -2
- data/lib/erubis/helper.rb +2 -2
- data/lib/erubis/helpers/rails_form_helper.rb +190 -0
- data/lib/erubis/helpers/rails_helper.rb +63 -28
- data/lib/erubis/local-setting.rb +2 -2
- data/lib/erubis/main.rb +2 -2
- data/lib/erubis/tiny.rb +2 -2
- data/test/assert-text-equal.rb +2 -2
- data/test/test-engines.rb +2 -2
- data/test/test-enhancers.rb +2 -2
- data/test/test-erubis.rb +2 -2
- data/test/test-main.rb +2 -2
- data/test/test-users-guide.rb +2 -2
- data/test/test.rb +2 -2
- data/test/testutil.rb +2 -2
- metadata +53 -44
- data/test/data/users-guide/stderr.log +0 -3
data/lib/erubis/enhancer.rb
CHANGED
data/lib/erubis/error.rb
CHANGED
data/lib/erubis/evaluator.rb
CHANGED
data/lib/erubis/generator.rb
CHANGED
data/lib/erubis/helper.rb
CHANGED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
###
|
|
2
|
+
### $Rev: 98 $
|
|
3
|
+
### $Release: 2.5.0 $
|
|
4
|
+
### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
|
5
|
+
###
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module Erubis
|
|
9
|
+
module Helpers
|
|
10
|
+
module RailsFormHelper
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module Erubis::Helpers::RailsFormHelper
|
|
17
|
+
|
|
18
|
+
def pp_template_filename(basename)
|
|
19
|
+
return "#{RAILS_ROOT}/app/views/#{controller.controller_name}/#{basename}.rhtml"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def pp_render_partial(basename)
|
|
23
|
+
basename = "_#{basename}" unless basename[0] == ?_
|
|
24
|
+
filename = pp_template_filename(basename)
|
|
25
|
+
klass = Erubis::Helpers::RailsHelper::PreprocessingEruby
|
|
26
|
+
eruby = klass.new(File.read(filename))
|
|
27
|
+
return eruby.evaluate(self)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def pp_error_on(object_name, method, &block)
|
|
31
|
+
s = ''
|
|
32
|
+
s << "<% _stag, _etag = _pp_error_tags(@#{object_name}.errors.on('#{method}'))%>"
|
|
33
|
+
s << "<%=_stag%>"
|
|
34
|
+
s << yield(object_name, method)
|
|
35
|
+
s << "<%=_etag%>"
|
|
36
|
+
return s
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def _pp_error_tags(value)
|
|
40
|
+
return value ? ['<div class="fieldWithErrors">', '</div>'] : ['', '']
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def _pp_remove_error_div(s)
|
|
44
|
+
s.sub!(/\A<div class="fieldWithErrors">(.*)<\/div>\z/, '\1')
|
|
45
|
+
return s
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def pp_tag_helper(helper, object_name, method, options={})
|
|
49
|
+
if object_name.is_a?(ActionView::Helpers::FormHelper)
|
|
50
|
+
object_name = object_name.object_name
|
|
51
|
+
end
|
|
52
|
+
unless options.key?(:value) || options.key?('value')
|
|
53
|
+
options['value'] = _?("h @#{object_name}.#{method}")
|
|
54
|
+
end
|
|
55
|
+
$stderr.puts "*** debug: pp_tag_helper(): options=#{options.inspect}"
|
|
56
|
+
return pp_error_on(object_name, method) {
|
|
57
|
+
s = __send__(helper, object_name, method, options)
|
|
58
|
+
_pp_remove_error_div(s)
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def pp_form_tag(url_for_options={}, options={}, *parameters_for_url, &block)
|
|
63
|
+
return form_tag(url_for_options, options, *parameters_for_url, &block)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#--
|
|
67
|
+
#def pp_form_for(object_name, *args, &block)
|
|
68
|
+
# return form_for(object_name, *args, &block)
|
|
69
|
+
#end
|
|
70
|
+
#++
|
|
71
|
+
|
|
72
|
+
def pp_text_field(object_name, method, options={})
|
|
73
|
+
return pp_tag_helper(:text_field, object_name, method, options)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def pp_password_field(object_name, method, options={})
|
|
77
|
+
return pp_tag_helper(:password_field, object_name, method, options)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def pp_hidden_field(object_name, method, options={})
|
|
81
|
+
return pp_tag_helper(:hidden_field, object_name, method, options)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def pp_file_field(object_name, method, options={})
|
|
85
|
+
return pp_tag_helper(:file_field, object_name, method, options)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def pp_text_area(object_name, method, options={})
|
|
89
|
+
return pp_tag_helper(:text_area, object_name, method, options)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def pp_check_box(object_name, method, options={}, checked_value="1", unchecked_value="0")
|
|
93
|
+
s = check_box(object_name, method, options, checked_value, unchecked_value)
|
|
94
|
+
s.sub!(/\schecked=\"checked\"/, '')
|
|
95
|
+
s.sub!(/type="checkbox"/, "\\&<%= _pp_check_box_checked?(@#{object_name}.#{method}, #{checked_value.inspect}) ? ' checked=\"checked\"' : '' %>")
|
|
96
|
+
return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def _pp_check_box_checked?(value, checked_value)
|
|
100
|
+
return ActionView::Helpers::InstanceTag::check_box_checked?(value, checked_value)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def pp_radio_button(object_name, method, tag_value, options={})
|
|
104
|
+
s = radio_button(object_name, method, tag_value, options)
|
|
105
|
+
s.sub!(/\schecked=\"checked\"/, '')
|
|
106
|
+
s.sub!(/type="radio"/, "\\&<%= _pp_radio_button_checked?(@#{object_name}.#{method}, #{tag_value.inspect}) ? ' checked=\"checked\"' : '' %>")
|
|
107
|
+
return pp_error_on(object_name, method) { _pp_remove_error_div(s) }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def _pp_radio_button_checked?(value, tag_value)
|
|
111
|
+
return ActionView::Helpers::InstanceTag::radio_button_checked?(value, tag_value)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def _pp_select(object, method, collection, priority_collection, options={}, html_options={})
|
|
115
|
+
return pp_error_on(object, method) do
|
|
116
|
+
s = ""
|
|
117
|
+
## start tag
|
|
118
|
+
s << "<select id=\"#{object}_#{method}\" name=\"#{object}[#{method}]\""
|
|
119
|
+
for key, val in html_options:
|
|
120
|
+
s << " #{key}=\"#{val}\""
|
|
121
|
+
end
|
|
122
|
+
s << ">\n"
|
|
123
|
+
## selected table
|
|
124
|
+
key = options.key?(:value) ? :value : (options.key?('value') ? 'value' : nil)
|
|
125
|
+
if key.nil? ; selected = "@#{object}.#{method}"
|
|
126
|
+
elsif (val=options[key]).nil? ; selected = nil
|
|
127
|
+
elsif val =~ /\A<%=(.*)%>\z/ ; selected = $1
|
|
128
|
+
else ; selected = val.inspect
|
|
129
|
+
end
|
|
130
|
+
s << "<% _table = {#{selected}=>' selected=\"selected\"'} %>\n" if selected
|
|
131
|
+
## <option> tags
|
|
132
|
+
if options[:include_blank] || options['include_blank']
|
|
133
|
+
s << "<option value=\"\"></option>\n"
|
|
134
|
+
end
|
|
135
|
+
unless priority_collection.blank?
|
|
136
|
+
_pp_select_options(s, priority_collection, selected, 'delete')
|
|
137
|
+
s << "<option value=\"\">-------------</option>\n"
|
|
138
|
+
end
|
|
139
|
+
_pp_select_options(s, collection, selected, '[]')
|
|
140
|
+
## end tag
|
|
141
|
+
s << "</select>"
|
|
142
|
+
s
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def _pp_select_options(s, collection, selected, operator)
|
|
147
|
+
for item in collection
|
|
148
|
+
value, text = item.is_a?(Array) ? item : [item, item]
|
|
149
|
+
if !selected
|
|
150
|
+
t = ''
|
|
151
|
+
elsif operator == 'delete'
|
|
152
|
+
t = "<%= _table.delete(#{value.inspect}) %>"
|
|
153
|
+
else
|
|
154
|
+
t = "<%= _table[#{value.inspect}] %>"
|
|
155
|
+
end
|
|
156
|
+
s << "<option value=\"#{h value}\"#{t}>#{h text}</option>\n"
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def pp_select(object, method, collection, options={}, html_options={})
|
|
161
|
+
return _pp_select(object, method, collection, nil, options, html_options)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def pp_collection_select(object, method, collection, value_method, text_method, options={}, html_options={})
|
|
165
|
+
collection2 = collection.collect { |e|
|
|
166
|
+
[e.__send__(value_method), e.__send__(text_method)]
|
|
167
|
+
}
|
|
168
|
+
return _pp_select(object, method, collection2, nil, options, html_options)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def pp_country_select(object, method, priority_countries=nil, options={}, html_options={})
|
|
172
|
+
collection = ActionView::Helpers::FormOptionsHelper::COUNTRIES
|
|
173
|
+
return _pp_select(object, method, collection, priority_countries, options, html_options)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def pp_time_zone_select(object, method, priority_zones=nil, options={}, html_options={})
|
|
177
|
+
model = options[:model] || options['model'] || TimeZone
|
|
178
|
+
collection = model.all.collect { |e| [e.name, e.to_s] }
|
|
179
|
+
return _pp_select(object, method, collection, priority_zones, options, html_options)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def pp_submit_tag(value="Save changes", options={})
|
|
183
|
+
return submit_tag(value, options)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def pp_image_submit_tag(source, options={})
|
|
187
|
+
return image_submit_tag(source, options)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
###
|
|
2
|
-
### $Rev:
|
|
3
|
-
### $Release: 2.
|
|
4
|
-
### copyright(c) 2006-
|
|
2
|
+
### $Rev: 99 $
|
|
3
|
+
### $Release: 2.5.0 $
|
|
4
|
+
### copyright(c) 2006-2008 kuwata-lab.com all rights reserved.
|
|
5
5
|
###
|
|
6
6
|
|
|
7
7
|
|
|
@@ -34,15 +34,11 @@ module Erubis
|
|
|
34
34
|
## #Erubis::Helpers::RailsHelper.show_src = false # set true for debugging
|
|
35
35
|
## #Erubis::Helpers::RailsHelper.preprocessing = true # set true to enable preprocessing
|
|
36
36
|
##
|
|
37
|
-
## 2.
|
|
37
|
+
## 2. restart web server.
|
|
38
38
|
##
|
|
39
|
-
##
|
|
40
|
-
##
|
|
41
|
-
##
|
|
42
|
-
## 3. restart web server.
|
|
43
|
-
##
|
|
44
|
-
## if Erubis::Helper::Rails.show_src is ture, Erubis prints converted Ruby code
|
|
45
|
-
## into log file ('log/development.log' or so). This may be useful for debug.
|
|
39
|
+
## if Erubis::Helper::Rails.show_src is true, Erubis prints converted Ruby code
|
|
40
|
+
## into log file ('log/development.log' or so). if false, it doesn't.
|
|
41
|
+
## if nil, Erubis prints converted Ruby code if ENV['RAILS_ENV'] == 'development'.
|
|
46
42
|
##
|
|
47
43
|
module RailsHelper
|
|
48
44
|
|
|
@@ -70,7 +66,7 @@ module Erubis
|
|
|
70
66
|
end
|
|
71
67
|
|
|
72
68
|
#cattr_accessor :show_src
|
|
73
|
-
@@show_src =
|
|
69
|
+
@@show_src = nil
|
|
74
70
|
|
|
75
71
|
def self.show_src
|
|
76
72
|
@@show_src
|
|
@@ -80,7 +76,7 @@ module Erubis
|
|
|
80
76
|
@@show_src = flag
|
|
81
77
|
end
|
|
82
78
|
|
|
83
|
-
##-----
|
|
79
|
+
##----- preprocessing --------------------
|
|
84
80
|
@@preprocessing = false
|
|
85
81
|
def self.preprocessing
|
|
86
82
|
@@preprocessing
|
|
@@ -126,19 +122,21 @@ unless ActionView::Base.private_instance_methods.include?(method_name) ||
|
|
|
126
122
|
end
|
|
127
123
|
|
|
128
124
|
|
|
129
|
-
if ActionPack::VERSION::
|
|
125
|
+
if ActionPack::VERSION::MAJOR >= 2 ### Rails 2.X
|
|
130
126
|
|
|
131
127
|
|
|
132
|
-
#
|
|
128
|
+
# Method to create the source code for a given template.
|
|
133
129
|
def create_template_source(extension, template, render_symbol, locals)
|
|
134
130
|
if template_requires_setup?(extension)
|
|
135
131
|
body = case extension.to_sym
|
|
136
|
-
when :rxml
|
|
132
|
+
when :rxml, :builder
|
|
133
|
+
content_type_handler = (controller.respond_to?(:response) ? "controller.response" : "controller")
|
|
134
|
+
"#{content_type_handler}.content_type ||= Mime::XML\n" +
|
|
137
135
|
"xml = Builder::XmlMarkup.new(:indent => 2)\n" +
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
template +
|
|
137
|
+
"\nxml.target!\n"
|
|
140
138
|
when :rjs
|
|
141
|
-
"
|
|
139
|
+
"controller.response.content_type ||= Mime::JS\n" +
|
|
142
140
|
"update_page do |page|\n#{template}\nend"
|
|
143
141
|
end
|
|
144
142
|
else
|
|
@@ -152,14 +150,14 @@ if ActionPack::VERSION::MINOR <= 12 ### Rails 1.1
|
|
|
152
150
|
|
|
153
151
|
locals_code = ""
|
|
154
152
|
locals_keys.each do |key|
|
|
155
|
-
locals_code << "#{key} = local_assigns[:#{key}]
|
|
153
|
+
locals_code << "#{key} = local_assigns[:#{key}]\n"
|
|
156
154
|
end
|
|
157
155
|
|
|
158
156
|
"def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend"
|
|
159
157
|
end
|
|
160
158
|
|
|
161
159
|
|
|
162
|
-
|
|
160
|
+
elsif ActionPack::VERSION::MINOR > 12 ### Rails 1.2
|
|
163
161
|
|
|
164
162
|
|
|
165
163
|
# Create source code for given template
|
|
@@ -192,6 +190,39 @@ else ### Rails 1.2 or later
|
|
|
192
190
|
end
|
|
193
191
|
|
|
194
192
|
|
|
193
|
+
elsif ActionPack::VERSION::MINOR <= 12 ### Rails 1.1
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# Create source code for given template
|
|
197
|
+
def create_template_source(extension, template, render_symbol, locals)
|
|
198
|
+
if template_requires_setup?(extension)
|
|
199
|
+
body = case extension.to_sym
|
|
200
|
+
when :rxml
|
|
201
|
+
"xml = Builder::XmlMarkup.new(:indent => 2)\n" +
|
|
202
|
+
"@controller.headers['Content-Type'] ||= 'application/xml'\n" +
|
|
203
|
+
template
|
|
204
|
+
when :rjs
|
|
205
|
+
"@controller.headers['Content-Type'] ||= 'text/javascript'\n" +
|
|
206
|
+
"update_page do |page|\n#{template}\nend"
|
|
207
|
+
end
|
|
208
|
+
else
|
|
209
|
+
#body = ERB.new(template, nil, @@erb_trim_mode).src
|
|
210
|
+
body = convert_template_into_ruby_code(template)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
@@template_args[render_symbol] ||= {}
|
|
214
|
+
locals_keys = @@template_args[render_symbol].keys | locals
|
|
215
|
+
@@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h }
|
|
216
|
+
|
|
217
|
+
locals_code = ""
|
|
218
|
+
locals_keys.each do |key|
|
|
219
|
+
locals_code << "#{key} = local_assigns[:#{key}] if local_assigns.has_key?(:#{key})\n"
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
"def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend"
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
|
|
195
226
|
end ###
|
|
196
227
|
|
|
197
228
|
|
|
@@ -210,10 +241,12 @@ class ActionView::Base # :nodoc:
|
|
|
210
241
|
klass = Erubis::Helpers::RailsHelper.engine_class
|
|
211
242
|
properties = Erubis::Helpers::RailsHelper.init_properties
|
|
212
243
|
show_src = Erubis::Helpers::RailsHelper.show_src
|
|
213
|
-
|
|
244
|
+
show_src = ENV['RAILS_ENV'] == 'development' if show_src.nil?
|
|
245
|
+
##----- preprocessing -------------------
|
|
214
246
|
if Erubis::Helpers::RailsHelper.preprocessing
|
|
215
247
|
preprocessor = Erubis::Helpers::RailsHelper::PreprocessingEruby.new(template)
|
|
216
|
-
template = self.instance_eval(preprocessor.src)
|
|
248
|
+
#template = self.instance_eval(preprocessor.src)
|
|
249
|
+
template = preprocessor.evaluate(self)
|
|
217
250
|
logger.debug "** Erubis: preprocessed==<<'END'\n#{template}END\n" if show_src
|
|
218
251
|
end
|
|
219
252
|
##----------------------------------------
|
|
@@ -223,15 +256,17 @@ class ActionView::Base # :nodoc:
|
|
|
223
256
|
src
|
|
224
257
|
end
|
|
225
258
|
|
|
226
|
-
##----- preprocessing
|
|
227
|
-
def
|
|
259
|
+
##----- preprocessing -------------------
|
|
260
|
+
def _p(arg)
|
|
228
261
|
return "<%=#{arg}%>"
|
|
229
262
|
end
|
|
230
|
-
|
|
231
|
-
|
|
263
|
+
def _P(arg)
|
|
264
|
+
return "<%=h(#{arg})%>"
|
|
265
|
+
end
|
|
266
|
+
alias _? _p
|
|
232
267
|
def _decode(arg)
|
|
233
268
|
arg = arg.to_s
|
|
234
|
-
arg.gsub!(/%3C%25
|
|
269
|
+
arg.gsub!(/%3C%25(?:=|%3D)(.*?)%25%3E/) { "<%=#{CGI.unescape($1)}%>" }
|
|
235
270
|
arg.gsub!(/<%=(.*?)%>/) { "<%=#{CGI.unescapeHTML($1)}%>" }
|
|
236
271
|
return arg
|
|
237
272
|
end
|
data/lib/erubis/local-setting.rb
CHANGED
data/lib/erubis/main.rb
CHANGED
data/lib/erubis/tiny.rb
CHANGED
data/test/assert-text-equal.rb
CHANGED