DRY up your views

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    DRY up your views - Presentation Transcript

    1. smartbomb DRY your views! Lachie Cox lachie@smartbomb.com.au r o ro
    2. smartbomb bmobtrams DRY ‣ don’t repeat yourself, mmkay?
    3. smartbomb bmobtrams MVC ‣ v is for vexing
    4. smartbomb bmobtrams DRYing models is easy
    5. smartbomb bmobtrams DRYing ctrllrs is OK
    6. smartbomb bmobtrams DRYing views is vexatious
    7. WET views smartbomb bmobtrams sca olding
    8. smartbomb bmobtrams
    9. WET views smartbomb bmobtrams erb layouts partials
    10. smartbomb bmobtrams
    11. smartbomb bmobtrams <% labeled_form_for :thing, things_path do |f| %> <%= f.text_field :name %> <%= f.text_field :aspect %> <%= f.check_box :existing %> <%= submit_tag 'Save' %> <% end %>
    12. smartbomb bmobtrams WASTE <% labeled_form_for :thing, things_path do |f| %> <%= f.text_field :name %> <%= f.text_field :aspect %> <%= f.check_box :existing %> <%= submit_tag 'Save' %> <% end %>
    13. waste baaaad smartbomb bmobtrams
    14. smartbomb bmobtrams components engines
    15. smartbomb bmobtrams
    16. smartbomb bmobtrams ‣ http://codefluency.com/2007/5/18/ when-v-is-for-vexing ‣ Bruce Williams
    17. smartbomb bmobtrams Don’t Fear Helpers Make them APIs
    18. smartbomb bmobtrams Make them semantic
    19. helpers as api smartbomb bmobtrams <%= describe person, :blank_message => \"Nobody\" %>
    20. helpers as api smartbomb bmobtrams <% rounded_box do %> <h2>Products</h2> <% end %>
    21. stencil smartbomb bmobtrams ‣ http://stencil.rubyforge.org
    22. smartbomb bmobtrams semantic helpers as objects
    23. a cart stencil smartbomb bmobtrams class CartStencil < Stencil ... def to_s render(:partial => 'shared/cart', :object => @cart) end def summary if @cart.blank? \"Your cart is empty. Buy stuff!\" else \"You have #{@cart.size} items in your cart.\" end end end
    24. a cart stencil smartbomb bmobtrams <% cart = cart() %> <!-- CartStencil.new --> <%= cart.summary %> <%= cart %> <!-- cart.to_s -->
    25. more than a stencil smartbomb bmobtrams module CartControllerHelper ... end class UserController include CartControllerHelper load_cart :only => [:show] end
    26. smartbomb bmobtrams C V cart cart (mixin) (stencil)
    27. smartbomb bmobtrams Stencil + Mixin + javascript + CSS &c.
    28. smartbomb bmobtrams lightweight widgetty thingo
    29. smartbomb bmobtrams
    30. smartbomb bmobtrams DRY javascript
    31. smartbomb bmobtrams RJS
    32. smartbomb bmobtrams
    33. smartbomb bmobtrams document.getElementById(\"foobar\") $(\"foobar\")
    34. smartbomb bmobtrams use prototype ‣ until optimisation
    35. smartbomb bmobtrams <%= link_to_function 'declaim', 'alert(\"yay for smarties!\")' %> <%= link_to 'delete', smarty_path(42), :method => :delete %>
    36. smartbomb bmobtrams
    37. srsly, wtf? smartbomb bmobtrams <a onclick=\"var f = document.createElement ('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\" href=\"/smarties/1\">delete</a>
    38. smartbomb bmobtrams
    39. smartbomb bmobtrams be less obtrusive
    40. smartbomb bmobtrams use less code
    41. smartbomb bmobtrams OMG javascript has classes too!
    42. smartbomb bmobtrams use & reuse
    43. smartbomb bmobtrams lowpro ‣ http://danwebb.net/lowpro
    44. smartbomb bmobtrams reusable behaviours
    45. smartbomb bmobtrams
    46. smartbomb bmobtrams
    47. smartbomb bmobtrams HTML <a class=\"forgotten\" href=\"/accounts/forgotten\"> I've forgotten my password. </a>
    48. smartbomb bmobtrams HTML <a class=\"forgotten\" href=\"/accounts/forgotten\"> I've forgotten my password. </a> javascript Event.addBehavior({ '.forgotten': Toggler('forgotten_password','cancel') })
    49. smartbomb bmobtrams
    50. smartbomb bmobtrams DRY its good for the soul

    + lachielachie, 3 years ago

    custom

    1225 views, 1 favs, 0 embeds more stats

    My presentation at RORO sydney september meetup.

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1225
      • 1225 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 11
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories