Displaying 10 results from an estimated 10 matches for "local_assign".
Did you mean:
local_assigns
2008 Mar 23
6
Locals do not appear in partial unless collection is explici
Maybe I''m misunderstanding something but it appears as if
<%= render :partial => @items, @locals => { :this => ''that'' } %>
does not give the local variable this but this one does:
<%= render :partial => ''items/item'', :collection => @items, @locals => {
:this => ''that'' } %>
Shouldn''t they mean
2006 Mar 12
0
ERB and Builder template engines shouldn''t be so heavily wired in ActionView::Base
...der) should be placed
inside the vendor directory.
3. Every template engine should have a base class
ActionView::Engines::EngineName with these methods:
self::template_exists?( render_options={} )
self::type # return :rhtml, :rxml, :vcrb, etc.
initialize( action_view )
render( render_options={}, local_assigns={} )
4. Only used template engines will be then registered in environment.rb:
ActionView::Base.register_template_handler( ''erb'' )
# does: require( "vendor/erb.rb" )
ActionView::Base.register_template_handler( ''view_controller'' )
# does: require( &qu...
2010 Jan 19
0
best way to set default for an optional local in a partial?
...9;'s the best way to set the default value of an optional local
variable in a partial template?
In the past I''ve used
<% foo = default_value unless (defined? foo) %>
But http://api.rubyonrails.org/classes/ActionView/Base.html says *not*
to use (defined? foo) and instead use (local_assigns.has_key? :foo) thus
<% foo = default_value unless (local_assigns.has_key? :foo) %>
Some have suggested
<% foo ||= default_value %>
which has the benefit of compact syntax, but will override passed values
of nil and false. Some have also suggested
<% foo = default_value i...
2006 Jan 03
3
render :partial stops setting local variables.
I''m not sure what happened, or what change has caused this to happen, but
render :partial (or any render for that matter, doesn''t seem to let me set
local variables via the local_assigns argument hash.
for example
<%= render :partial ''edit'', :username => @user.username %>
used to allow that username was a local variable in my _edit.rhtml partial
template.
example:
<p><b>Username:</b> <%= username %></p>
Could this be a...
2008 May 08
0
stub sub partials when testing partial with rspec
...gerous function
def block_render_except unblocked
ActionView::Partials.class_eval do
public
def self.set_unblocked partial
@@unblocked = partial
end
alias_method :orig_render_partial,:render_partial
def render_partial(partial_path, object_assigns = nil,
local_assigns = nil) #:nodoc:
if partial_path.to_s == @@unblocked
orig_render_partial(partial_path, object_assigns,
local_assigns)
else
return " "
end
end
end
ActionView::Partials.set_unblocked unblocked
end
usage:
block_render_except ...
2009 Oct 28
2
render :file cached?
In my application I have a controller/view that displays the contents
of an audit log file
def audit_log
render :layout => ''table'', :file => AUDIT_LOG
end
The audit log is updated frequently but the render call does not re-
read the file so it gets stale. Is there a way to tell render to
check the file timestamp and reload as needed?
2005 Dec 19
1
Preserving fallback with RJS
...9;'rxml''
elsif javascript_template_exists?(template_path): ''rjs''
else
raise ActionViewError, "No rhtml, rxml, rjs or delegate
template found for #{template_path}"
end
end
def render_file(template_path, use_full_path = true, local_assigns = {})
@first_render = template_path if @first_render.nil?
if use_full_path
template_extension = pick_template_extension(template_path)
template_file_name = full_template_path(template_path,
template_extension)
else
template_file_name = template_path...
2008 May 29
2
Render partial yields "dynamic constant assignment"
...line of HTML code in the partial. There is no line
72! Here is the error:
SyntaxError in Building_blocks#preview
Showing building_blocks/_BB02.html.erb where line #72 raised:
compile error
C:/Ruby_Development/sbtool/app/views/building_blocks/_BB02.html.erb:-2:
dynamic constant assignment
BB02 = local_assigns[:BB02]
^
C:/Ruby_Development/sbtool/app/views/building_blocks/_BB02.html.erb:-1:
dynamic constant assignment
BB02_counter = local_assigns[:BB02_counter]
Extracted source (around line #72):
69: </html>
70:
Application Trace:
app/views/building_blocks/_BB02.html.erb:72:in `compile_temp...
2007 May 28
1
Rails matcher render_template is wrong when using GetText, looking for flexible solution
...y "index_en.rhtml").
The source of this mismatch is that GetText overrides
ActionView::Base.render_file, testing each possible localized template
path and passes the first existing path to the original render_file
method :
return render_file_without_locale(localized_path, use_full_path,
local_assigns) if file_exists? localized_path
This line always evaluates to true in RSpec context, but to false in
the application.
After a lot of digging I found out that RspecOnRails overrides
file_exists? with a stub when integrate_views is not set
(lib/spec/rails/dsl/behaviour/controller.rb:57):
@templa...
2007 Aug 14
12
expect_render, why does there need to be a warning
There is a warning on the web site about expect_render and stub_render:
"WARNING: expect_render and stub_render, while very useful, act
differently from standard Message Expectations (a.k.a. mock
expectations), which would never pass calls through to the real
object. This can be very confusing when there are failures if you''re
not aware of this fact, because some calls will be