ruby-on-railscomfortable-mexican-sofa

How to pass parameters to partial in Comfortable Mexican Sofa?


How to pass parameters to partial in Comfortable Mexican Sofa. I have something like this:

module MySnippetHelper

  def my_partial
    # add something into array
  end

end

Partial:

 <% my_partial.each do |item| %>
     # some text to display
  <% end unless my_partial.empty? %>

And I call in my snippet in Comfortable Mexican Sofa:

{{ cms:partial:snippets/my_partial }} 

How can I pass a value to the partial so it could print something like this:

 <% my_partial.each do |item| %>
     <%= # My variable that I have passed to the partial %>
  <% end unless my_partial.empty? %>

I get the display right, but I can't make it to display my custom variable to the partial


Solution

  • Today, I am guessing, I will be answering to my own questions :)

    The answer for this one is this:

    Change:

    {{ cms:partial:snippets/my_partial }} 
    

    To this:

    {{ cms:partial:snippets/my_partial:"your value you want to pass in"}}
    

    And then in partial you can use:

      <% my_partial.each do |item| %>
         <%= param_1 %>
      <% end unless my_partial.empty? %>
    

    See documentation at https://github.com/comfy/comfortable-mexican-sofa/wiki/Tags You can pass as many parameters as you want. I somehow missed that when I was first reading.