Set partial default local values

Hello, is there any way to define a default value for partial locals?

Example:

I have a template that includes a partial like this:

<%= partial(“mypartial”, :locals => { :test => false }) %>

Setting the “test” variable to “false” on “mypartial”.

But inside “mypartial”, I want that the default value of “test” to be “true”. So, if I include the partial like this:

<%= partial(“mypartial” %>

“test” will be true.

Any help?

Thanks!

You can try to create a variable called test <% test = false %>, but not sure whether this works.
I’m still a neophyte and try to learn myself something about ruby and MM.

I know this is a silly work around but it worked for me in the past. I basically tested to see if test existed if it did then I’m in the false state, and if it didn’t then I’m in a true state. I know backwards thinking. So, I do something super bad like:

<% unless test %>
    do something useful
<% else %>
    do something special
<% end %>

I’m not sure if it’s the best way, but for me it’s the simplest. Inside your partial (“mypartial”):

<% test ||= true %>

Basically, if test is defined, then it will use that value, if not, it will use true.