github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

quackingduck / fancyviews

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 13
    • 3
  • Source
  • Commits
  • Network (3)
  • Issues (0)
  • Downloads (2)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (2)
    • v1.4.1
    • v1.4.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Views extension for Sinatra — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

ignore gemspec file 
quackingduck (author)
Tue Dec 15 16:17:58 -0800 2009
commit  cffd917a14017ae26e165a6b2ca1623f5d94b927
tree    deaaa642687066ff32673fe4ce0e8aeb0eca419c
parent  b6265e8059b0746c987ebff3bb959917ce95bdb7
fancyviews /
name age
history
message
file .gitignore Loading commit data...
file README.markdown
file Rakefile
file VERSION
file examples.rb
directory lib/
directory test/
README.markdown

Fancyviews

Fancyviews is a sinatra plugin for developers already using haml and sass.

The problem with the view layer of most codebases: adding code is quick and easy but removing that same code two weeks later is fraught with peril.

This asymmetry is the unfortunate result of organizing view code by type instead of use. The HTML/DOM code goes in one bucket and the styles & javascript get their own buckets. When the time comes to make a change that requires modification to all three types of view code, the specific lines must be located in each bucket.

Fancyviews flips this around and allows you to organize your view code by use but renders it to the browser as if it was organized by type. You put all the code in one view file, nesting your javascript and sass beneath the script and style haml filters:

# fancy.haml    
:style
  #fancy
    :font-family Helvetica
    :font-size 200px
    :font-weight bold
    :color black
    :margin 0
    :padding 10px
    :letter-spacing -4px

:script
  document.getElementById('fancy').onclick = function() { alert('Fancy click') } 

%h1#fancy Oooh! Fancy

And now you use the view method wherever you want include this:

# anywhere.haml
// ... some other code
view :fancy
// ... more codez

The haml will be rendered and included, just like normal partial rendering, but the styles and scripts will be captured by fancy goats. Then somewhere in your layout you steal them back from those sneaky goats with the styles and scripts (note the plurals) methods:

# layout.haml
%head
  = styles
%body
  ...
  = scripts

For syntax highlighting in textmate, use this haml bundle: http://github.com/quackingduck/ruby-haml.tmbundle/tree/master and for sass use this one: http://github.com/quackingduck/ruby-sass-tmbundle/tree/master

The style method can also import other sass files present in the views directory:

= styles(:import => :base)
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server