merb-core 0.9.13 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -3
- data/lib/merb-core.rb +84 -41
- data/lib/merb-core/bootloader.rb +71 -60
- data/lib/merb-core/config.rb +31 -17
- data/lib/merb-core/controller/abstract_controller.rb +35 -35
- data/lib/merb-core/controller/exceptions.rb +14 -9
- data/lib/merb-core/controller/merb_controller.rb +22 -20
- data/lib/merb-core/controller/mime.rb +5 -5
- data/lib/merb-core/controller/mixins/authentication.rb +11 -8
- data/lib/merb-core/controller/mixins/conditional_get.rb +7 -7
- data/lib/merb-core/controller/mixins/controller.rb +15 -15
- data/lib/merb-core/controller/mixins/render.rb +16 -16
- data/lib/merb-core/controller/mixins/responder.rb +23 -23
- data/lib/merb-core/controller/template.rb +17 -17
- data/lib/merb-core/core_ext/hash.rb +2 -2
- data/lib/merb-core/core_ext/kernel.rb +19 -18
- data/lib/merb-core/dispatch/cookies.rb +13 -0
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +12 -1
- data/lib/merb-core/dispatch/dispatcher.rb +6 -5
- data/lib/merb-core/dispatch/request.rb +56 -52
- data/lib/merb-core/dispatch/request_parsers.rb +7 -7
- data/lib/merb-core/dispatch/router.rb +14 -14
- data/lib/merb-core/dispatch/router/behavior.rb +31 -31
- data/lib/merb-core/dispatch/router/cached_proc.rb +13 -1
- data/lib/merb-core/dispatch/router/resources.rb +9 -9
- data/lib/merb-core/dispatch/router/route.rb +60 -7
- data/lib/merb-core/dispatch/session.rb +21 -15
- data/lib/merb-core/dispatch/session/container.rb +10 -8
- data/lib/merb-core/dispatch/session/cookie.rb +12 -11
- data/lib/merb-core/dispatch/session/memcached.rb +4 -2
- data/lib/merb-core/dispatch/session/memory.rb +8 -6
- data/lib/merb-core/dispatch/session/store_container.rb +6 -5
- data/lib/merb-core/dispatch/worker.rb +28 -10
- data/lib/merb-core/gem_ext/erubis.rb +4 -2
- data/lib/merb-core/logger.rb +3 -22
- data/lib/merb-core/plugins.rb +5 -5
- data/lib/merb-core/rack.rb +1 -1
- data/lib/merb-core/rack/adapter.rb +5 -1
- data/lib/merb-core/rack/adapter/abstract.rb +15 -10
- data/lib/merb-core/rack/adapter/ebb.rb +4 -2
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/fcgi.rb +3 -1
- data/lib/merb-core/rack/adapter/irb.rb +10 -1
- data/lib/merb-core/rack/adapter/mongrel.rb +5 -2
- data/lib/merb-core/rack/adapter/runner.rb +3 -1
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/thin.rb +4 -1
- data/lib/merb-core/rack/adapter/thin_turbo.rb +1 -0
- data/lib/merb-core/rack/adapter/webrick.rb +8 -34
- data/lib/merb-core/rack/application.rb +2 -2
- data/lib/merb-core/rack/handler/mongrel.rb +7 -0
- data/lib/merb-core/rack/helpers.rb +1 -1
- data/lib/merb-core/rack/middleware.rb +7 -1
- data/lib/merb-core/rack/middleware/conditional_get.rb +3 -0
- data/lib/merb-core/rack/middleware/content_length.rb +2 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +4 -0
- data/lib/merb-core/rack/middleware/profiler.rb +3 -1
- data/lib/merb-core/rack/middleware/static.rb +7 -1
- data/lib/merb-core/rack/middleware/tracer.rb +1 -0
- data/lib/merb-core/rack/stream_wrapper.rb +35 -30
- data/lib/merb-core/server.rb +17 -16
- data/lib/merb-core/tasks/gem_management.rb +1 -1
- data/lib/merb-core/tasks/merb.rb +3 -1
- data/lib/merb-core/tasks/merb_rake_helper.rb +1 -1
- data/lib/merb-core/test.rb +8 -8
- data/lib/merb-core/test/helpers.rb +1 -1
- data/lib/merb-core/test/helpers/cookie_jar.rb +16 -2
- data/lib/merb-core/test/helpers/mock_request_helper.rb +13 -13
- data/lib/merb-core/test/helpers/request_helper.rb +1 -1
- data/lib/merb-core/test/helpers/route_helper.rb +2 -2
- data/lib/merb-core/test/matchers.rb +3 -3
- data/lib/merb-core/test/matchers/request_matchers.rb +1 -1
- data/lib/merb-core/test/run_spec.rb +1 -1
- data/lib/merb-core/test/tasks/spectasks.rb +1 -1
- data/lib/merb-core/test/test_ext/hpricot.rb +1 -1
- data/lib/merb-core/test/test_ext/rspec.rb +2 -2
- data/lib/merb-core/test/test_ext/string.rb +1 -1
- data/lib/merb-core/version.rb +1 -1
- metadata +8 -22
- data/lib/merb-core/test/matchers/view_matchers.rb +0 -231
- data/lib/merb-core/test/webrat.rb +0 -37
- data/lib/merb-core/vendor/nokogiri/css.rb +0 -6
- data/lib/merb-core/vendor/nokogiri/css/generated_parser.rb +0 -653
- data/lib/merb-core/vendor/nokogiri/css/generated_tokenizer.rb +0 -159
- data/lib/merb-core/vendor/nokogiri/css/node.rb +0 -95
- data/lib/merb-core/vendor/nokogiri/css/parser.rb +0 -24
- data/lib/merb-core/vendor/nokogiri/css/parser.y +0 -198
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rb +0 -9
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rex +0 -63
- data/lib/merb-core/vendor/nokogiri/css/xpath_visitor.rb +0 -159
@@ -20,7 +20,7 @@ module Merb::RenderMixin
|
|
20
20
|
# ==== Returns
|
21
21
|
# Hash:: An options hash
|
22
22
|
#
|
23
|
-
#
|
23
|
+
# :api: public
|
24
24
|
def default_render_options
|
25
25
|
self._default_render_options ||= {}
|
26
26
|
end
|
@@ -30,7 +30,7 @@ module Merb::RenderMixin
|
|
30
30
|
# ==== Parameters
|
31
31
|
# opts<Hash>:: An options hash
|
32
32
|
#
|
33
|
-
#
|
33
|
+
# :api: public
|
34
34
|
def render_options(opts)
|
35
35
|
self._default_render_options = opts
|
36
36
|
end
|
@@ -47,7 +47,7 @@ module Merb::RenderMixin
|
|
47
47
|
# ==== Returns
|
48
48
|
# Hash:: The default render options.
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# :api: public
|
51
51
|
def layout(layout)
|
52
52
|
self.default_render_options.update(:layout => (layout || false))
|
53
53
|
end
|
@@ -57,7 +57,7 @@ module Merb::RenderMixin
|
|
57
57
|
# ==== Returns
|
58
58
|
# ~to_s:: The layout that was previously set.
|
59
59
|
#
|
60
|
-
#
|
60
|
+
# :api: public
|
61
61
|
def default_layout
|
62
62
|
self.default_render_options.delete(:layout)
|
63
63
|
end
|
@@ -96,7 +96,7 @@ module Merb::RenderMixin
|
|
96
96
|
# If you pass a Hash as the first parameter, it will be moved to opts and
|
97
97
|
# "thing" will be the current action
|
98
98
|
#
|
99
|
-
#
|
99
|
+
# :api: public
|
100
100
|
def render(thing = nil, opts = {})
|
101
101
|
# render :format => :xml means render nil, :format => :xml
|
102
102
|
opts, thing = thing, nil if thing.is_a?(Hash)
|
@@ -201,7 +201,7 @@ module Merb::RenderMixin
|
|
201
201
|
# The transformed object will not be used in a layout unless a :layout is
|
202
202
|
# explicitly passed in the opts.
|
203
203
|
#
|
204
|
-
#
|
204
|
+
# :api: public
|
205
205
|
def display(object, thing = nil, opts = {})
|
206
206
|
template_opt = thing.is_a?(Hash) ? thing.delete(:template) : opts.delete(:template)
|
207
207
|
|
@@ -283,7 +283,7 @@ module Merb::RenderMixin
|
|
283
283
|
# In this case, "one" will be available in the partial through the local
|
284
284
|
# variable named +number+.
|
285
285
|
#
|
286
|
-
#
|
286
|
+
# :api: public
|
287
287
|
def partial(template, opts={})
|
288
288
|
|
289
289
|
# partial :foo becomes "#{controller_name}/_foo"
|
@@ -340,7 +340,7 @@ module Merb::RenderMixin
|
|
340
340
|
# ==== Returns
|
341
341
|
# Hash:: The options hash that was passed in.
|
342
342
|
#
|
343
|
-
#
|
343
|
+
# :api: private
|
344
344
|
def _handle_options!(opts)
|
345
345
|
self.status = opts.delete(:status).to_i if opts[:status]
|
346
346
|
headers["Location"] = opts.delete(:location) if opts[:location]
|
@@ -365,7 +365,7 @@ module Merb::RenderMixin
|
|
365
365
|
# one in to this method), and not found. No error will be raised if no
|
366
366
|
# layout was specified, and the default layouts were not found.
|
367
367
|
#
|
368
|
-
#
|
368
|
+
# :api: private
|
369
369
|
def _get_layout(layout = nil)
|
370
370
|
return false if layout == false
|
371
371
|
|
@@ -406,7 +406,7 @@ module Merb::RenderMixin
|
|
406
406
|
# Array[Symbol, String]::
|
407
407
|
# A pair consisting of the template method and location.
|
408
408
|
#
|
409
|
-
#
|
409
|
+
# :api: private
|
410
410
|
def _template_for(context, content_type, controller=nil, template=nil, locals=[])
|
411
411
|
template_method, template_location = nil, nil
|
412
412
|
|
@@ -442,7 +442,7 @@ module Merb::RenderMixin
|
|
442
442
|
# ==== Returns
|
443
443
|
# String:: The method, if it exists. Otherwise return nil.
|
444
444
|
#
|
445
|
-
#
|
445
|
+
# :api: private
|
446
446
|
def _template_method_for(template_location, locals)
|
447
447
|
meth = Merb::Template.template_for(template_location, [], locals)
|
448
448
|
meth && self.respond_to?(meth) ? meth : nil
|
@@ -456,7 +456,7 @@ module Merb::RenderMixin
|
|
456
456
|
# ==== Parameters
|
457
457
|
# obj<Object>:: The key in the thrown_content hash. Defaults to :for_layout.
|
458
458
|
#
|
459
|
-
#
|
459
|
+
# :api: public
|
460
460
|
def catch_content(obj = :for_layout)
|
461
461
|
@_caught_content[obj] || ''
|
462
462
|
end
|
@@ -466,7 +466,7 @@ module Merb::RenderMixin
|
|
466
466
|
# ==== Parameters
|
467
467
|
# obj<Object>:: The key in the thrown_content hash. Defaults to :for_layout.
|
468
468
|
#
|
469
|
-
#
|
469
|
+
# :api: public
|
470
470
|
def thrown_content?(obj = :for_layout)
|
471
471
|
@_caught_content.key?(obj)
|
472
472
|
end
|
@@ -488,7 +488,7 @@ module Merb::RenderMixin
|
|
488
488
|
# throw_content(:foo, "Foo")
|
489
489
|
# catch_content(:foo) #=> "Foo"
|
490
490
|
#
|
491
|
-
#
|
491
|
+
# :api: public
|
492
492
|
def throw_content(obj, string = nil, &block)
|
493
493
|
unless string || block_given?
|
494
494
|
raise ArgumentError, "You must pass a block or a string into throw_content"
|
@@ -508,7 +508,7 @@ module Merb::RenderMixin
|
|
508
508
|
# @raise [ArgumentError]
|
509
509
|
# Neither string nor block given
|
510
510
|
#
|
511
|
-
#
|
511
|
+
# :api: public
|
512
512
|
def append_content(obj, string = nil, &block)
|
513
513
|
unless string || block_given?
|
514
514
|
raise ArgumentError, "You must pass a block or a string into append_content"
|
@@ -524,7 +524,7 @@ module Merb::RenderMixin
|
|
524
524
|
# ==== Parameters
|
525
525
|
# obj<Object>:: The key in the thrown_content hash. Defaults to :for_layout.
|
526
526
|
#
|
527
|
-
#
|
527
|
+
# :api: public
|
528
528
|
def clear_content(obj = :for_layout)
|
529
529
|
@_caught_content.delete(obj) unless @_caught_content[obj].nil?
|
530
530
|
end
|
@@ -105,7 +105,7 @@ module Merb
|
|
105
105
|
# ==== Parameters
|
106
106
|
# base<Module>:: The module that ResponderMixin was mixed into
|
107
107
|
#
|
108
|
-
#
|
108
|
+
# :api: private
|
109
109
|
def self.included(base)
|
110
110
|
base.extend(ClassMethods)
|
111
111
|
base.class_eval do
|
@@ -133,7 +133,7 @@ module Merb
|
|
133
133
|
# ==== Examples
|
134
134
|
# provides :html, :xml
|
135
135
|
#
|
136
|
-
#
|
136
|
+
# :api: public
|
137
137
|
def provides(*formats)
|
138
138
|
self.class_provided_formats |= formats
|
139
139
|
end
|
@@ -147,7 +147,7 @@ module Merb
|
|
147
147
|
# ==== Returns
|
148
148
|
# Array[Symbol]:: List of formats passed in.
|
149
149
|
#
|
150
|
-
#
|
150
|
+
# :api: public
|
151
151
|
def only_provides(*formats)
|
152
152
|
clear_provides
|
153
153
|
provides(*formats)
|
@@ -163,7 +163,7 @@ module Merb
|
|
163
163
|
# Array[Symbol]::
|
164
164
|
# List of formats that remain after removing the ones not to provide.
|
165
165
|
#
|
166
|
-
#
|
166
|
+
# :api: public
|
167
167
|
def does_not_provide(*formats)
|
168
168
|
self.class_provided_formats -= formats
|
169
169
|
end
|
@@ -173,7 +173,7 @@ module Merb
|
|
173
173
|
# ==== Returns
|
174
174
|
# Array:: An empty Array.
|
175
175
|
#
|
176
|
-
#
|
176
|
+
# :api: public
|
177
177
|
def clear_provides
|
178
178
|
self.class_provided_formats.clear
|
179
179
|
end
|
@@ -183,7 +183,7 @@ module Merb
|
|
183
183
|
# ==== Returns
|
184
184
|
# Array[Symbol]:: [:html].
|
185
185
|
#
|
186
|
-
#
|
186
|
+
# :api: public
|
187
187
|
def reset_provides
|
188
188
|
only_provides(:html)
|
189
189
|
end
|
@@ -195,7 +195,7 @@ module Merb
|
|
195
195
|
# controller. It starts with what has been set in the controller (or
|
196
196
|
# :html by default) but can be modifed on a per-action basis.
|
197
197
|
#
|
198
|
-
#
|
198
|
+
# :api: private
|
199
199
|
def _provided_formats
|
200
200
|
@_provided_formats ||= class_provided_formats.dup
|
201
201
|
end
|
@@ -215,7 +215,7 @@ module Merb
|
|
215
215
|
# ==== Returns
|
216
216
|
# Array[Symbol]:: List of formats passed in.
|
217
217
|
#
|
218
|
-
#
|
218
|
+
# :api: public
|
219
219
|
def provides(*formats)
|
220
220
|
if @_content_type
|
221
221
|
raise ContentTypeAlreadySet, "Cannot modify provided_formats because content_type has already been set"
|
@@ -234,7 +234,7 @@ module Merb
|
|
234
234
|
# ==== Returns
|
235
235
|
# Array[Symbol]:: List of formats passed in.
|
236
236
|
#
|
237
|
-
#
|
237
|
+
# :api: public
|
238
238
|
def only_provides(*formats)
|
239
239
|
@_provided_formats = []
|
240
240
|
provides(*formats)
|
@@ -252,7 +252,7 @@ module Merb
|
|
252
252
|
# Array[Symbol]::
|
253
253
|
# List of formats that remain after removing the ones not to provide.
|
254
254
|
#
|
255
|
-
#
|
255
|
+
# :api: public
|
256
256
|
def does_not_provide(*formats)
|
257
257
|
@_provided_formats -= formats.flatten
|
258
258
|
end
|
@@ -264,7 +264,7 @@ module Merb
|
|
264
264
|
# 4. Look for one that is provided, in order of request
|
265
265
|
# 5. Raise 406 if none found
|
266
266
|
#
|
267
|
-
#
|
267
|
+
# :api: private
|
268
268
|
def _perform_content_negotiation
|
269
269
|
if (fmt = params[:format]) && !fmt.empty?
|
270
270
|
accepts = [fmt.to_sym]
|
@@ -312,7 +312,7 @@ module Merb
|
|
312
312
|
# ==== Returns
|
313
313
|
# Symbol:: The content-type that will be used for this controller.
|
314
314
|
#
|
315
|
-
#
|
315
|
+
# :api: public
|
316
316
|
def content_type(fmt = nil)
|
317
317
|
self.content_type = (fmt || _perform_content_negotiation) unless @_content_type
|
318
318
|
@_content_type
|
@@ -331,7 +331,7 @@ module Merb
|
|
331
331
|
# ==== Returns
|
332
332
|
# Symbol:: The content-type that was passed in.
|
333
333
|
#
|
334
|
-
#
|
334
|
+
# :api: plugin
|
335
335
|
def content_type=(type)
|
336
336
|
unless Merb.available_mime_types.has_key?(type)
|
337
337
|
raise Merb::ControllerExceptions::NotAcceptable.new("Unknown content_type for response: #{type}")
|
@@ -384,7 +384,7 @@ module Merb
|
|
384
384
|
# The index used for sorting accept types. A lower value indicates higher
|
385
385
|
# priority.
|
386
386
|
#
|
387
|
-
#
|
387
|
+
# :api: private
|
388
388
|
def initialize(entry,index)
|
389
389
|
@index = index
|
390
390
|
|
@@ -407,7 +407,7 @@ module Merb
|
|
407
407
|
# -1, 0 or 1, depending on whether entry has a lower, equal or higher
|
408
408
|
# priority than the accept type being compared.
|
409
409
|
#
|
410
|
-
#
|
410
|
+
# :api: private
|
411
411
|
def <=>(entry)
|
412
412
|
if entry.quality == quality
|
413
413
|
@index <=> entry.index
|
@@ -425,27 +425,27 @@ module Merb
|
|
425
425
|
# True if the accept types are equal, i.e. if the synonyms for this
|
426
426
|
# accept type includes the entry media range.
|
427
427
|
#
|
428
|
-
#
|
428
|
+
# :api: private
|
429
429
|
def eql?(entry)
|
430
430
|
synonyms.include?(entry.media_range)
|
431
431
|
end
|
432
432
|
|
433
433
|
# An alias for eql?.
|
434
434
|
#
|
435
|
-
#
|
435
|
+
# :api: private
|
436
436
|
def ==(entry); eql?(entry); end
|
437
437
|
|
438
438
|
# ==== Returns
|
439
439
|
# Fixnum:: A hash based on the super range.
|
440
440
|
#
|
441
|
-
#
|
441
|
+
# :api: private
|
442
442
|
def hash; super_range.hash; end
|
443
443
|
|
444
444
|
# ==== Returns
|
445
445
|
# Array[String]::
|
446
446
|
# All Accept header values, such as "text/html", that match this type.
|
447
447
|
#
|
448
|
-
#
|
448
|
+
# :api: private
|
449
449
|
def synonyms
|
450
450
|
return @syns if @syns
|
451
451
|
if _mime = mime
|
@@ -455,7 +455,7 @@ module Merb
|
|
455
455
|
end
|
456
456
|
end
|
457
457
|
|
458
|
-
#
|
458
|
+
# :api: private
|
459
459
|
def mime
|
460
460
|
@mime ||= Merb.available_mime_types[Merb::ResponderMixin::MIMES[@media_range]]
|
461
461
|
end
|
@@ -465,7 +465,7 @@ module Merb
|
|
465
465
|
# The primary media range for this accept type, i.e. either the first
|
466
466
|
# synonym or, if none exist, the media range.
|
467
467
|
#
|
468
|
-
#
|
468
|
+
# :api: private
|
469
469
|
def super_range
|
470
470
|
synonyms.first || @media_range
|
471
471
|
end
|
@@ -473,7 +473,7 @@ module Merb
|
|
473
473
|
# ==== Returns
|
474
474
|
# Symbol: The type as a symbol, e.g. :html.
|
475
475
|
#
|
476
|
-
#
|
476
|
+
# :api: private
|
477
477
|
def to_sym
|
478
478
|
Merb.available_mime_types.select{|k,v|
|
479
479
|
v[:accepts] == synonyms || v[:accepts][0] == synonyms[0]}.flatten.first
|
@@ -482,7 +482,7 @@ module Merb
|
|
482
482
|
# ==== Returns
|
483
483
|
# String:: The accept type as a string, i.e. the media range.
|
484
484
|
#
|
485
|
-
#
|
485
|
+
# :api: private
|
486
486
|
def to_s
|
487
487
|
@media_range
|
488
488
|
end
|
@@ -26,7 +26,7 @@ module Merb::Template
|
|
26
26
|
# character replaced based on the non-alphanumeric character
|
27
27
|
# to avoid edge-case collisions.
|
28
28
|
#
|
29
|
-
#
|
29
|
+
# :api: private
|
30
30
|
def template_name(path)
|
31
31
|
path = File.expand_path(path)
|
32
32
|
path.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_")
|
@@ -48,7 +48,7 @@ module Merb::Template
|
|
48
48
|
# ==== Returns
|
49
49
|
# IO#path:: An IO object that responds to path (File or VirtualFile).
|
50
50
|
#
|
51
|
-
#
|
51
|
+
# :api: plugin
|
52
52
|
# @overridable
|
53
53
|
def load_template_io(path)
|
54
54
|
File.open(path, "r")
|
@@ -64,7 +64,7 @@ module Merb::Template
|
|
64
64
|
# ==== Returns
|
65
65
|
# <String>:: name of the method that inlines the template.
|
66
66
|
#
|
67
|
-
#
|
67
|
+
# :api: private
|
68
68
|
def template_for(path, template_stack = [], locals=[])
|
69
69
|
path = File.expand_path(path)
|
70
70
|
|
@@ -85,7 +85,7 @@ module Merb::Template
|
|
85
85
|
# ==== Returns
|
86
86
|
# Boolean:: Whether or not the template for the provided path needs to be recompiled
|
87
87
|
#
|
88
|
-
#
|
88
|
+
# :api: private
|
89
89
|
def needs_compilation?(path, locals)
|
90
90
|
return true if Merb::Config[:reload_templates] || !METHOD_LIST[path]
|
91
91
|
|
@@ -99,7 +99,7 @@ module Merb::Template
|
|
99
99
|
# ==== Returns
|
100
100
|
# Array:: Extension strings.
|
101
101
|
#
|
102
|
-
#
|
102
|
+
# :api: plugin
|
103
103
|
def template_extensions
|
104
104
|
EXTENSIONS.keys
|
105
105
|
end
|
@@ -124,7 +124,7 @@ module Merb::Template
|
|
124
124
|
# Even though this method supports inlining into any module, the method
|
125
125
|
# must be available to instances of AbstractController that will use it.
|
126
126
|
#
|
127
|
-
#
|
127
|
+
# :api: private
|
128
128
|
def inline_template(io, locals=[], mod = Merb::InlineTemplates)
|
129
129
|
full_file_path = File.expand_path(io.path)
|
130
130
|
engine_neutral_path = full_file_path.gsub(/\.[^\.]*$/, "")
|
@@ -145,7 +145,7 @@ module Merb::Template
|
|
145
145
|
# ==== Returns
|
146
146
|
# Class:: The engine.
|
147
147
|
#
|
148
|
-
#
|
148
|
+
# :api: private
|
149
149
|
def engine_for(path)
|
150
150
|
path = File.expand_path(path)
|
151
151
|
EXTENSIONS[path.match(/\.([^\.]*)$/)[1]]
|
@@ -169,7 +169,7 @@ module Merb::Template
|
|
169
169
|
# ==== Example
|
170
170
|
# Merb::Template.register_extensions(Merb::Template::Erubis, ["erb"])
|
171
171
|
#
|
172
|
-
#
|
172
|
+
# :api: plugin
|
173
173
|
def register_extensions(engine, extensions)
|
174
174
|
raise ArgumentError, "The class you are registering does not have a compile_template method" unless
|
175
175
|
engine.respond_to?(:compile_template)
|
@@ -189,7 +189,7 @@ module Merb::Template
|
|
189
189
|
# locals<Array[Symbol]>:: A list of locals to assign from the args passed into the compiled template.
|
190
190
|
# mod<Module>:: The module that the compiled method will be placed into.
|
191
191
|
#
|
192
|
-
#
|
192
|
+
# :api: private
|
193
193
|
def self.compile_template(io, name, locals, mod)
|
194
194
|
template = ::Erubis::BlockAwareEruby.new(io.read)
|
195
195
|
_old_verbose, $VERBOSE = $VERBOSE, nil
|
@@ -220,7 +220,7 @@ module Merb::Template
|
|
220
220
|
# <p>Some Foo content!</p>
|
221
221
|
# <% end %>
|
222
222
|
#
|
223
|
-
#
|
223
|
+
# :api: private
|
224
224
|
def capture_erb(*args, &block)
|
225
225
|
_old_buf, @_erb_buf = @_erb_buf, ""
|
226
226
|
block.call(*args)
|
@@ -229,7 +229,7 @@ module Merb::Template
|
|
229
229
|
ret
|
230
230
|
end
|
231
231
|
|
232
|
-
#
|
232
|
+
# :api: private
|
233
233
|
def concat_erb(string, binding)
|
234
234
|
@_erb_buf << string
|
235
235
|
end
|
@@ -243,36 +243,36 @@ end
|
|
243
243
|
|
244
244
|
module Erubis
|
245
245
|
module BlockAwareEnhancer
|
246
|
-
#
|
246
|
+
# :api: private
|
247
247
|
def add_preamble(src)
|
248
248
|
src << "_old_buf, @_erb_buf = @_erb_buf, ''; "
|
249
249
|
src << "@_engine = 'erb'; "
|
250
250
|
end
|
251
251
|
|
252
|
-
#
|
252
|
+
# :api: private
|
253
253
|
def add_postamble(src)
|
254
254
|
src << "\n" unless src[-1] == ?\n
|
255
255
|
src << "_ret = @_erb_buf; @_erb_buf = _old_buf; _ret.to_s;\n"
|
256
256
|
end
|
257
257
|
|
258
|
-
#
|
258
|
+
# :api: private
|
259
259
|
def add_text(src, text)
|
260
260
|
src << " @_erb_buf.concat('" << escape_text(text) << "'); "
|
261
261
|
end
|
262
262
|
|
263
|
-
#
|
263
|
+
# :api: private
|
264
264
|
def add_expr_escaped(src, code)
|
265
265
|
src << ' @_erb_buf.concat(' << escaped_expr(code) << ');'
|
266
266
|
end
|
267
267
|
|
268
|
-
#
|
268
|
+
# :api: private
|
269
269
|
def add_stmt2(src, code, tailch)
|
270
270
|
src << code
|
271
271
|
src << " ).to_s; " if tailch == "="
|
272
272
|
src << ';' unless code[-1] == ?\n
|
273
273
|
end
|
274
274
|
|
275
|
-
#
|
275
|
+
# :api: private
|
276
276
|
def add_expr_literal(src, code)
|
277
277
|
if code =~ /(do|\{)(\s*\|[^|]*\|)?\s*\Z/
|
278
278
|
src << ' @_erb_buf.concat( ' << code << "; "
|