0

I want to run this block only a condition is satisfied

<% if condition %>
 <% progressive_render do %>
   SLOW CODE HERE
 <% end %>
<% end %>

IF condition = true

SLOW CODE should be runnned wrapped by "progressive_render"

IF condition = true

SLOW CODE shoud be runned not wrapped by progressive_render. So runned anyway.

sparkle
  • 7,530
  • 22
  • 69
  • 131
  • 1
    `if condition = true` twice? – Sebastián Palma Dec 07 '19 at 12:16
  • 1
    Just to be extra careful – Mark Dec 07 '19 at 12:57
  • "[Stack Overflow question checklist](https://meta.stackoverflow.com/questions/260648/stack-overflow-question-checklist)" is your friend. Your question doesn't make sense. As @SebastianPalma pointed out you are asking about two identical conditions expecting different results. Also, please note that grammar/spelling are very important on SO as the site is like an online encyclopedia, not a message board. – the Tin Man Dec 07 '19 at 18:02

1 Answers1

1

You can replace the if-else condition with a guard clause (plus unless condition):

<% SLOW CODE HERE unless condition %>
<% progressive_render { SLOW CODE HERE } %>
Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59