Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Sinatra 和苗条。在一个苗条的模板中,如果变量为真,我想停止渲染。像这样的代码:
- if @lock p.alert this page is locked. - stop_render
我尝试使用 return 并且只生成了一个空页面。显然,简单的返回不会使刚刚呈现的 html 标记保持苗条。那么有没有办法中途停止渲染模板并保留渲染的内容?
考虑将您不想渲染的模板部分放入部分中,然后有条件地渲染它:
- if @lock p.alert | This page is locked. - else = slim :'partials/_my_partial'