0

I am using Sinatra and slim. In one slim template I would like to stop render if a variable is true. Code like this:

- if @lock
    p.alert this page is locked.
    - stop_render

I tried to use return and that just generated a empty page. Apparently a plain return does not keep the html markup slim just rendered. so is there a way to stop render a template halfway and keep the rendered content?

johnsyweb
  • 136,902
  • 23
  • 188
  • 247
Kurt Liu
  • 610
  • 2
  • 8
  • 15

1 Answers1

2

Consider putting the part of your template that you don't want to render into a partial and then render it conditionally:

- if @lock
  p.alert
    | This page is locked.
- else
  = slim :'partials/_my_partial'
trushkevich
  • 2,657
  • 1
  • 28
  • 37