Module ActionView::Partials
引用
Partials can have their own layouts applied to them. These layouts are different than the ones that are specified globally
for the entire action, but they work in a similar fashion. Imagine a list with two types of users:
<!-- app/views/users/index.html.erb -->
Here's the administrator:
<%= render :partial => "user", :layout => "administrator", :locals => { :user => administrator } %>
Here's the editor:
<%= render :partial => "user", :layout => "editor", :locals => { :user => editor } %>
<!-- app/views/users/_user.html.erb -->
Name: <%= user.name %>
<!-- app/views/users/_administrator.html.erb -->
<div id="administrator">
Budget: $<%= user.budget %>
<%= yield %>
</div>
<!-- app/views/users/_editor.html.erb -->
<div id="editor">
Deadline: $<%= user.deadline %>
<%= yield %>
</div>
...this will return:
Here's the administrator:
<div id="administrator">
Budget: $<%= user.budget %>
Name: <%= user.name %>
</div>
Here's the editor:
<div id="editor">
Deadline: $<%= user.deadline %>
Name: <%= user.name %>
</div>
You can also apply a layout to a block within any template:
<!-- app/views/users/_chief.html.erb -->
<% render(:layout => "administrator", :locals => { :user => chief }) do %>
Title: <%= chief.title %>
<% end %>
...this will return:
<div id="administrator">
Budget: $<%= user.budget %>
Title: <%= chief.name %>
</div>
分享到:
相关推荐
《Real-Time_3D_Rendering_with_DirectX_and_HLSL》是一本专注于实时三维渲染技术的专著,尤其强调了DirectX和High-Level Shading Language(HLSL)的应用。这本书是为那些想要深入理解现代游戏开发、虚拟现实、可视...
Written by active members of the Direct3D community, Practical Rendering and Computation with Direct3D 11 provides a deep understanding of both the high and low level concepts related to using Direct...
《Practical Rendering and Computation with Direct3D11》是一本深入探讨Direct3D 11编程技术的专业书籍。Direct3D是微软开发的一个图形应用程序接口(API),主要用于Windows平台上的游戏开发、科学可视化和专业...
《Practical Rendering and Computation with Direct3D 11》是一本深入探讨Direct3D 11渲染与计算技术的专业书籍。源码是该书理论知识的实际应用展示,同时也是实现一个完整DirectX 11游戏引擎的基础。在这个压缩包...
- **非摄影真实渲染 (Non-photorealistic rendering)**:一种计算机图形学技术,用于模拟非现实世界中的渲染效果,如手绘风格、卡通风格等。 - **水彩 (Watercolor)**:一种绘画技法,使用水溶性颜料在纸张或其他...
ShaderX3 Advanced Rendering with DirectX and OpenGL
《实时三维渲染:DirectX与HLSL实战》是一本深度探讨实时图形编程技术的专著,主要聚焦于DirectX和High-Level Shader Language (HLSL)的应用。这本书旨在帮助读者掌握利用这两种强大的工具进行实时3D场景渲染的技能...
标题:“ShaderX3-Advanced Rendering with DirectX and OpenGL”(英文原文) 描述:这本名为ShaderX3的书籍,副标题为“Advanced Rendering with DirectX and OpenGL”,是学习着色器(shader)技术的宝贵资源。...
### 实时渲染带有大气效果的行星技术 #### 摘要 本文介绍了一种实时技术,用于渲染带有大气散射效果的行星。该方法基于Nishita的大气模型,能够真实地模拟空气分子和气溶胶的行为,并结合了一个连续细节级别的行星...
"Programming with OpenGL Advanced Rendering" 主要关注的是如何利用OpenGL的高级特性来实现复杂的图形渲染效果。这包括但不限于阴影、光照、纹理映射、着色器编程、几何变换、抗锯齿、景深模糊、后处理效果等。 1...