Commit Graph

58 Commits

Author SHA1 Message Date
José Valim
50aa876f32 Make rendering in ActionView happen through _render_template, as the rendering which comes from ActionController. 2009-12-31 18:40:20 -08:00
José Valim
75ba102a80 Remove ActionView inline logging to ActiveSupport::Notifications and create ActionController::Base#log_event, so everything can be logged within one listener. Also expose log_process_action as a hook for different modules to include their own information during the action processing. This allow ActiveRecord to hook and any other ORM. Finally, this commit changes 'Processing' and 'Rendering' in logs to 'Processed' and 'Rendered' because at the point it's logged, everying already happened. 2009-12-26 20:28:53 +01:00
José Valim
8a36e907d2 More <%= render(@posts) %> optimization. 2009-12-26 14:11:04 +01:00
José Valim
ff1a1c0b4d Optimize <%= render(@posts) %>. 2009-12-26 14:11:04 +01:00
José Valim
c86424a72d Break instrumentation into several end-points so rendering of partials can be optimized. 2009-12-26 14:11:04 +01:00
José Valim
48273a44c6 Wrap layout rendering in one method: _render_layout (this should make partial instrumentation easier). 2009-12-26 14:11:04 +01:00
David Heinemeier Hansson
a110ff0fca Dont introspect inline templates for the logger and cleanup a few styling issues 2009-12-21 16:03:04 -08:00
Joshua Peek
97be8537eb Fix @renderer warning 2009-12-01 22:58:56 -06:00
Nathan Weizenbaum
cbded53671 When rendering layouts with blocks, use #capture to avoid assuming that the return value is the block's content.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
2009-11-05 20:08:04 -08:00
José Valim
684c2dc208 Remove ActionMailer helpers and rely on AbstractController one. 2009-11-01 02:23:48 +01:00
Yehuda Katz
8dcf91ca11 First pass at cleaning up action caching 2009-10-28 16:54:00 -04:00
Yehuda Katz
b9ce8216fa Fix a bug where render :text could not handle yield :symbol. Fixes guides generation 2009-10-10 00:31:12 -10:00
Yehuda Katz
16a48a95e3 Fix issue with standalone ActionView 2009-10-09 00:55:00 -10:00
Michael Koziarski
9415935902 Switch to on-by-default XSS escaping for rails.
This consists of:

  * String#html_safe! a method to mark a string as 'safe'
  * ActionView::SafeBuffer a string subclass which escapes anything unsafe which is concatenated to it
  * Calls to String#html_safe! throughout the rails helpers
  * a 'raw' helper which lets you concatenate trusted HTML from non-safety-aware sources (e.g. presantized strings in the DB)
  * New ERB implementation based on erubis which uses a SafeBuffer instead of a String

Hat tip to Django for the inspiration.
2009-10-08 09:31:20 +13:00
Erik Ostrom
8ffc2e3b8d Ported the new ActionView::TestCase from 2-3-stable to master [#3260
state:resolved]

The test case now mimicks the template environment more closely, so it's
possible to use render, load helper dependencies.

This also fixes assert_select, and similar assertions. Because view tests
and helpers generally don't render full templates assert_select looks
first in rendered and then in output_buffer to find the rendered output.

Additional `master'-only changes: Made the Action Pack Rakefile run the
ActionView::TestCase tests, and made ActionView::Rendering#_render_text
always return a string.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-28 13:31:30 -05:00
Joshua Peek
610b81beca Clean up log output for rendered templates 2009-09-24 12:30:13 -05:00
Yehuda Katz
ccf28d2499 Fixes ActionMailer regression [#3059 state:resolved] 2009-08-15 20:38:50 -07:00
Yehuda Katz
9b552fb300 Caches and cache clearing seems to actually work, but the actual architecture is kind of messy. Next: CLEAN UP. 2009-08-15 12:32:01 -07:00
Yehuda Katz
9f5cd0156a More cleanup of ActionView and reduction in need for blocks in some cases:
* only one of partial_name or :as will be available as a local
  * `object` is removed
  * Simplify _layout_for in most cases.
    * Remove <% render :partial do |args| %>
    * <% render :partial do %> still works fine
2009-08-15 12:32:01 -07:00
Yehuda Katz
27adcd1c1a Clean up ActionView some:
* Call _evaluate_assigns_and_ivars at the two entry points so we don't have to
    do a check at every render.
  * Make template.render viable without having to go through a wrapper method
  * Remove old TemplateHandler#render(template, local_assigns) path so we don't have
    to set self.template every time we render a template.
  * Move Template rescuing code to Template#render so it gets caught every time.
  * Pull in some tests from Pratik that test render @object in ActionView
2009-08-15 12:32:01 -07:00
Yehuda Katz
9e62d6d1c0 Tentatively accept the ":as or :object, but not both" solution 2009-08-11 15:03:53 -07:00
Yehuda Katz
4945d82239 Further experimentation. Was able to cut the cost of rendering 100 partials in a collection in half.
To discuss: What are the desired semantics (if any) for layouts in a collection. There are no
  tests for it at present, and I'm not sure if it's needed at all.

  Deprecated on this branch: `object` pointing at the current object in partials. You can still
  use the partial name, or use :as to achieve the same thing. This is obviously up for discussion.
2009-08-11 15:03:53 -07:00
Yehuda Katz
33f01fb1f6 Cache some more things to improve partial perf 2009-08-09 04:12:08 -03:00
Yehuda Katz
0ab40b039b Went from 25% slower partials (vs. 2.3) to 10% faster. More to come. 2009-08-09 04:12:08 -03:00
Yehuda Katz
d7415f792c Clean up partial object some more; replace passing around a block to a single block ivar 2009-08-09 04:12:08 -03:00
Yehuda Katz
bf412c9ec6 Clean up initializer and some of the internals of PartialRenderer 2009-08-09 04:12:08 -03:00
Jeremy Kemper
b5b1576aa9 Ruby 1.9 compat: can't implicitly set instance var using block arg 2009-08-08 23:04:25 -07:00
Yehuda Katz
d0301e13f4 First pass at making partial rendering an Object. More cleanup to come. 2009-08-08 12:44:26 -03:00
Yehuda Katz
010a0c92eb Rename find_by_parts and find_by_parts? to find and exists? 2009-08-07 15:00:12 -03:00
Yehuda Katz
bfe58ac05d Get all ActionController partial rendering to use ActionView's partial code. Consequences:
* It is not possible to always pre-determine the layout before going to ActionView.
    This was *already* broken for render :partial => @object, :layout => true. This is
    now handled by overriding render_to_body in layouts.rb and manually injecting the
    partial's response. This needs to be done in ActionController since ActionController
    knows enough to get _layout_for_option. There is probably a better abstraction here.
  * As a result, all partial rendering can correctly restrict their layouts to the mime
    type of the rendered partial. This could have previously caused a bug in some edge cases.
  * If other layout-like options are added, they might need to add special code for the
    case of render :partial. We should try to think of an alternate solution, if possible,
    but this works for the cases we know of now.
2009-08-07 11:33:54 -03:00
Yehuda Katz
606e950ccb Whitespace 2009-08-07 06:32:54 -03:00
Yehuda Katz
d94ba11295 Continue reworking the partial path.
* TODO: Review ActionController calling render_template for certain partials.
    Might we be able to save logic by always delegating to AV's render_partial?
2009-08-07 06:32:17 -03:00
Yehuda Katz
493d84ce2f Modify various partial methods to carry along the block that can be passed in with render
* _render_single_template, which renders a template without layout
  * _render_partial_unknown_type, which renders a partial of unknown type
    (the entry method for most partial rendering; supports strings, objects, and collections)
  * _render_partial_object, which renders a partial for a single object.
  * extracted _render_partial_path so it can be used to render the spacer without going
    through the public render :partial
2009-08-07 05:40:01 -03:00
Yehuda Katz
59e475e3a6 Some more AV work:
* rename _render_partial to _render_partial_unknown_type to reflect that for this call, 
  	we don't know the type.
  * Merge _render_partial_with_block and _render_partial_with_layout to _render_partial
    * TODO: Check to see if any more logic can be shared
    * TODO: See about streamlining block path so we can get rid of @_proc_for_layout
  * Remove @exempt_from_layout as it is no longer needed
2009-08-07 03:48:28 -03:00
Yehuda Katz
0612fd0f09 Replace _render_template_with_layout with _render_template since the layout is optional 2009-08-07 03:18:45 -03:00
Yehuda Katz
b3e199f698 Some more AV refactoring:
* remove no longer used _array_like_objects
  * _render_content_with_layout renamed to _render_content since layout it optional
  * remove check for optional layout before _render_content
2009-08-07 02:46:21 -03:00
Yehuda Katz
8534c5bf19 Start cleaning up partial path 2009-08-07 01:51:50 -03:00
Yehuda Katz
9b506484f1 This is handled by the resolver now 2009-08-07 01:51:32 -03:00
Yehuda Katz
70a440aa27 Clean up render @object a bit more. 2009-08-07 00:52:13 -03:00
Yehuda Katz
4ac9d391d3 Improve a path in _render_partial 2009-08-06 23:42:11 -03:00
Yehuda Katz
f0945409d9 replace _render_*_from_controller with render_* as they are intended to be public 2009-08-06 19:43:28 -03:00
Yehuda Katz
bb530923bc Simplify required "ActionView compliant" API 2009-07-19 21:53:02 +09:00
Joshua Peek
7aa730440c Remove deprecated implicit ivar assignment 2009-06-25 12:51:21 -05:00
Yehuda Katz + Carl Lerche
9f7eaea201 Minor ActionView cleanup 2009-06-18 12:08:50 -07:00
Yehuda Katz + Carl Lerche
497554fd10 Fix typo 2009-06-18 11:14:44 -07:00
Yehuda Katz + Carl Lerche
b4a91db441 Extract the layout proc into a method, and write documentation explaining what the proc does in various cases. 2009-06-17 18:55:10 -07:00
Yehuda Katz + Carl Lerche
a9ad763c86 Drive the final stake through @content_for_*'s heart! 2009-06-17 18:08:45 -07:00
Yehuda Katz + Carl Lerche
55ee0ba7f5 Cleaning up if defined?(ActionController::Http) blocks from the pre new base era. 2009-06-17 16:23:11 -07:00
Joshua Peek
4e50a35fa2 Break up DependencyModule's dual function of providing a "depend_on" DSL and "included" block DSL into separate modules. But, unify both approaches under AS::Concern. 2009-05-28 11:35:36 -05:00
Yehuda Katz + Carl Lerche
216309c165 Implemented redirects and partial rendering in new base. 2009-05-12 16:21:34 -07:00