Rails partials locals + strict locals
Rails
ActionView
local_assigns
<%= render partial: "company", locals: { company: @company, foobar: "/barr" }
a/v/companies/_company.html.erb
<div><%= company.name %></div> <%= link_to foobar, foobar if local_assigns[:foobar] %>
render "partial_name" #renders "_partial_name.html.erb" render "partial_name", var1: "foo", var2: "bar" # pass local variables to partial render "partial_name", local_assigns # pass all localy assign variables to partial (usefull to pass all variables of partial to next partial)
note: benefit of these is you can pass them to next partial
<%= render "kaminari/paginator_reskinned", **local_assigns %> <%= render partial: "kaminari/paginator_reskinned", locals: local_assigns %>
Strict locals
since Rails 7.1 you can do
a/v/companies/_company.html.erb
<%# locals: (company:) %> <div><%= company.name %>
Defaults
<%# locals: comany, active: params[:active]) -%>
<%# locals: (paypal: PaymentGateway.find_by_name("paypal"), braintree:...) -%>
sources: