From 1bda43c322ca201e975801eae93afff7f0bc648f Mon Sep 17 00:00:00 2001 From: Nikos Dimitrakopoulos Date: Tue, 23 Sep 2008 00:53:52 +0300 Subject: [PATCH] Added documentation about local variables inside views (Refs #242). --- lib/merb-core/controller/mixins/render.rb | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/lib/merb-core/controller/mixins/render.rb b/lib/merb-core/controller/mixins/render.rb index 2bb4730..bb511f1 100644 --- a/lib/merb-core/controller/mixins/render.rb +++ b/lib/merb-core/controller/mixins/render.rb @@ -82,6 +82,15 @@ module Merb::RenderMixin # ==== Alternatives # If you pass a Hash as the first parameter, it will be moved to opts and # "thing" will be the current action + # + # ==== Notes + # Be aware that views evaluate in controller context. That's just something + # you have to be aware of when naming local variables (inside the views). + # For example calling something like: + # <%= name %> + # inside a view which gets rendered in the context of a controller that + # has a "#name" method and a +name+ variable is not set explicitly before, + # results in calling the controller's "#name" method. #--- # @public def render(thing = nil, opts = {}) @@ -279,6 +288,9 @@ module Merb::RenderMixin # # In this case, "one" will not be available in the partial because "partial" # is already a helper method. + # + # Also keep in mind the note in #render method about variables' names + # inside views (and therefore partials also). def partial(template, opts={}) # partial :foo becomes "#{controller_name}/_foo" -- 1.6.0.1