Created
July 2, 2012 20:26
-
-
Save coreyward/3035488 to your computer and use it in GitHub Desktop.
If we quit treating <head> as HTML output and started thinking about it more like we do Rack middleware or HTTP headers (i.e. more object-oriented), I think we could gain a lot in the way of flexibility and structure, especially in complex applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| head << meta charset: :utf8 | |
| head << title 'My Application' | |
| head << stylesheet :application | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PostsController < ApplicationController | |
| head << javascript 'fancy_posts_displayer' | |
| def show | |
| @post = Post.find(params[:id]) | |
| head << javascript('disqus') if @post.allow_comments? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WeirdPagesController < ApplicationController | |
| head.remove stylesheet 'application' | |
| head.before title, meta(:chrome_frame) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment