`
wiisola
  • 浏览: 85629 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

#008_layouts和content_for

阅读更多
如果我们希望在不同页面使用不同的样式,我们可以使用layouts + content_for,如第8行:
<!-- layouts/application.rhtml -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html>   
  <head>   
    <title>Todo List</title>   
    <%= stylesheet_link_tag 'application' %>   
    <%= yield :head %>   
  </head>   
  <body>   
    <div id="container">   
      <h1>Todo List</h1>   
      <%= yield %>   
    </div>   
  </body>   
</html>

在视图中使用content_for标签,即可实现在该不同视图根据需要调用不同样式的功能。
<!-- projects/index.rhtml -->
<% content_for :head do %>   
  <%= stylesheet_link_tag 'projects' %>   
<% end %>

<h2>Projects</h2>   
<ul>   
  <% for project in @projects %>   
    <li><%= project.name %></li>   
  <% end %>
</ul>

话说Ryan还和大家讨论在一个视图中连接多个CSS是否合适,当然,这是合理的,也能给我们的开发带来更多的灵活。
分享到:
评论

相关推荐

    netWindows_0.3.0_pre2

    which can form the basis of many application interface layouts. Provides support for both horizontal and vertical splitting. - Combo Box widget: supports partial (incremental) option matching, first ...

    IseHarvest: TCP packet data re-assembler framework for network traffic content

    reconstructs files and web directory layouts in such a way to enable web content monitoring of network resources. By re-linking HTML and CSS files, it provides an after the fact visual of how web ...

    fio-devhub:FIO开发人员中心

    FIO开发人员中心入门网站布局: FIO-DEVHUB |-- _data (The yaml data used by the site) |-- _docs (The documentation pages) |-- _includes (Reusable html code) |-- _layouts (Layouts for different content ...

    Responsive.Web.Design.with.HTML5.and.CSS3.Essentials

    Design and deliver an optimal user experience for all devices About This Book Get to grips with the core functionality of RWD through examples Discover how to make layouts, content and media flexible,...

    Flexible Web Design Creating Liquid and Elastic Layouts with CSS.pdf

    pages and content are not fixed at one particular size By default web pages can change in width and height to accommodate the differing text sizes and window widths of the users This is true of both ...

    Apress.Android.Apps.for.Absolute.Beginners.2nd.edition

    Anybody can start building simple apps for the Android platform, and this book will show you how! Recently updated to include Android Jelly Bean, Android Apps for Absolute Beginners, Second Edition ...

    cms_design_using_php_and_jquery.pdf

    administrators can "design" their own page layouts. Chapter 11, Panels and Widgets – Part Two, finishes up the panels system by creating a Content Snippet widget, allowing ...

    Pro CSS3 Layout Techniques(Apress,2016)

    CSS1 allowed designers to separate content from presentation for the first time and CSS2 cemented support for advanced typographical control, but neither specification provided more than rudimentary ...

    d3.js in action

    数据可视化,manning2015年新作,d3... Then, you'll explore practical techniques for content creation, animation, and representing dynamic data—including interactive graphics and data streamed live ove...

    Drupal 6 Panels Cookbook

    The Drupal Panels module allows a site administrator to create customized layouts for multiple uses. At its core, it is a drag and drop content manager that lets you visually design a layout and place...

    液体导轨:渲染具有布局和部分支持的液体模板

    液体轨道 它允许您使用布局和部分支持来呈现.liquid模板。 它还提供了要在液体模板中使用的过滤器,标签,滴剂类。...{{ content_for_layout }} # It will render app/views/home/_partial.liquid wh

    D3.js in Action(Manning,2015)

    Then, you'll explore practical techniques for content creation, animation, and representing dynamic data—including interactive graphics and data streamed live over the web. The final chapters show ...

    Professional Android 4 Application Development 源代码

    Introducing Layouts To-Do List Example Introducing Fragments The Android Widget Toolbox Creating New Views Introducing Adapters Chapter 5: Intents and Broadcast Receivers Introducing Intents Creating ...

    Introduction.to.Android.Application.Development(4th,2013.12) pdf

    Reasonable Learning Curve for Developers 26 Enabling Development of Powerful Applications 26 Rich, Secure Application Integration 26 No Costly Obstacles for Development 27 A “Free Market” for ...

    Modern Auto Layout.zip

    Disabling the autoresizing mask (you will forget) Creating constraints with NSLayoutConstraint, Visual Format Language and Layout Anchors Which should you use? (Take a guess...) Safe area layout ...

    Wrox.Professional.Sitecore.Development.2012

    Sitecore is the leading provider of .NET...If you're looking for a solution for web content management, then Sitecore is your answer and this book will get you started using this valuable software today.

    Learning Drupal 6 Module Development

    * Interacting with the theme system to build crisp layouts * Creating richer user interfaces with Drupal's JavaScript libraries * Working with blocks, nodes, actions, and menus * Using a web service ...

    ViewPager 放大缩小左右移动

    * Sentinel value for no current active pointer. Used by * {@link #mActivePointerId}. */ private static final int INVALID_POINTER = -1; /** * Determines speed during touch scrolling */ ...

    plg_system_jat3.v1.2.2.zip

    modular structure - working with custom layouts and custom blocks push the content management even further; modern navigation systems - now you have five menu systems for you main navigation, meet ...

    Wrox.Professional.Android.Application.Development

    * Details for creating complex and compelling user interfaces by using, extending, and creating your own layouts and Views and using Menus. * A detailed look at data storage, retrieval, and sharing ...

Global site tag (gtag.js) - Google Analytics