Skip to content
This repository
Browse code

Caching template logging goes DEBUG

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1903 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 023c4d68cc298f3a4e66fe5f17ca7e99547768b6 1 parent 7fe3fd2
David Heinemeier Hansson dhh authored

Showing 1 changed file with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. +10 4 actionpack/lib/action_view/base.rb
14 actionpack/lib/action_view/base.rb
@@ -275,16 +275,19 @@ def read_template_file(template_path, extension)
275 275 @@loaded_templates[template_path] = info = File.read(template_path)
276 276 @@compiled_templates[template_path] = nil
277 277 end
  278 +
278 279 info
279 280 end
280 281
281 282 def evaluate_assigns(local_assigns = {})
282 283 @assigns.each { |key, value| instance_variable_set("@#{key}", value) }
283 284 saved_locals = {}
  285 +
284 286 local_assigns.each do |key, value|
285 287 varstr = "@_#{key}_"
286 288 saved_locals[varstr] = instance_variable_get(varstr)
287 289 instance_variable_set(varstr, value)
  290 +
288 291 unless self.respond_to?(key)
289 292 self.class.class_eval("def #{key}; #{varstr}; end")
290 293 self.class.class_eval("def #{key}=(v); #{varstr} = v; end")
@@ -296,8 +299,8 @@ def evaluate_assigns(local_assigns = {})
296 299
297 300 def compile_template(extension, template, file_name)
298 301 cache_name = file_name || template
  302 +
299 303 unless @@compiled_templates[cache_name]
300   - t_name, t_arg, t_code = nil
301 304 case extension
302 305 when :rhtml
303 306 t_name = 'run_html_'
@@ -308,6 +311,7 @@ def compile_template(extension, template, file_name)
308 311 t_arg = '(xml)'
309 312 t_code = template
310 313 end
  314 +
311 315 if file_name
312 316 i = file_name.index(@base_path)
313 317 l = @base_path.length
@@ -320,12 +324,14 @@ def compile_template(extension, template, file_name)
320 324 @@template_count += 1
321 325 t_name += @@template_count.to_s
322 326 end
  327 +
323 328 t_def = "def #{t_name}#{t_arg}; #{t_code}; end"
324 329 self.class.class_eval(t_def) rescue raise ActionViewError, "ERROR defining #{t_name}: #{t_def}"
325 330
326 331 @@compiled_templates[cache_name] = t_name.intern
327 332 @@loaded_templates[cache_name] = Time.now if file_name
328   - logger.info "Compiled template #{cache_name}\n ==> #{t_name}" if logger
  333 +
  334 + logger.debug "Compiled template #{cache_name}\n ==> #{t_name}" if logger
329 335 end
330 336 @@compiled_templates[cache_name]
331 337 end
@@ -334,7 +340,7 @@ def rhtml_render(extension, template, file_name, local_assigns)
334 340 render_sym = compile_template(:rhtml, template, file_name)
335 341 saved_locals = evaluate_assigns(local_assigns)
336 342 result = self.send(render_sym)
337   - saved_locals.each{ |k,v| instance_variable_set(k, v) }
  343 + saved_locals.each { |k,v| instance_variable_set(k, v) }
338 344 result
339 345 end
340 346
@@ -343,7 +349,7 @@ def rxml_render(extension, template, file_name, local_assigns)
343 349 render_sym = compile_template(:rxml, template, file_name)
344 350 saved_locals = evaluate_assigns(local_assigns)
345 351 result = self.send(render_sym, Builder::XmlMarkup.new(:indent => 2))
346   - saved_locals.each{ |k,v| instance_variable_set(k, v) }
  352 + saved_locals.each { |k,v| instance_variable_set(k, v) }
347 353 result
348 354 end
349 355

0 comments on commit 023c4d6

Please sign in to comment.
Something went wrong with that request. Please try again.