Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Supercharge Your Toolchain: Haml, Sass, CoffeeScript, Git, and Heroku

Supercharge Your Toolchain: Haml, Sass, CoffeeScript, Git, and Heroku

Learn how to write faster markup with Haml, smarter CSS with Sass, and better JavaScript with CoffeeScript. We’ll touch on the benefits of a git repository and the ease of deploying to Heroku. Intended for anyone interested in more expedient tools.

Christopher Webb

August 25, 2012
Tweet

More Decks by Christopher Webb

Other Decks in Programming

Transcript

  1. <article id=“featured”> <h1 class=“title”>Polaroid Fingerstache</h1> <div class=“date”>Mon, August 20, 2011</div>

    <p>Polaroid scenster salvia fingerstache, tweet readymade hella wes anderson lo-fi squid traffaut occupy leggings ethical.</p> </article>
  2. <h1 class=“vip”>American Apparel</h1> <div class=“button”>direct trade</div> <div id=”featured” class=“deal”>Fixed gear</div>

    HTML %h1.vip American Apparel .button direct trade #featured.deal Fixed gear HAML Classes & IDs
  3. <link href=“foo.css” rel=“stylesheet”> <a class=“external” href=“#”>Farm-to-table</a> <input type=“checkbox” selected=“selected”> HTML

    %link{:href => “foo.css”, :rel => “stylesheet”} %a.external{:href => “#”} Farm-to-table %input(type=“checkbox” selected) HAML Attributes
  4. <article> <h1><a href=“#”>Selvage</a></h1> <p>Selvage freegan swag cliche vinyl bushwick.</p> </article>

    HTML %article %h1 %a{:href => “#”} Groupon %p Selvage freegan swag cliche vinyl bushwick. HAML Nesting
  5. !!! 5 %html{lang: "en-us"} %head %meta{charset: "utf-8"} %title Conspirator %link{rel:"stylesheet",

    href: "/stylesheets/main.css"} %body #wrap %header %h1 %a{:href => “/”} Conspirator %nav %ul %li %a{:href => “/about”} About %li %a{:href => “/work”} Work %li %a{:href => “/contact”} Contact %section#main - @entries.each do |entry| %article %h3.title= entry.title %p.date= entry.posted.strftime("%A, %B %d, %Y") %p= entry.body Nesting
  6. %p = [‘Hello’, ‘Prototype’, ‘Camp’].join “ ” = link_to ‘View

    All Names’, names_path, {:class => ‘view-all’} HAML <p>Hello Prototype Camp</p> <a class=“view-all” href=“/names”>View All Names</a> HTML Ruby Evaluation
  7. - foo = “A foolish consistency is the” - foo

    << “ hobgoblin” - foo << “ of little minds.” %p= foo - username = “Jay Gatsby” #greeting= “Welcome, #{username}!” HAML <p>A foolish consistency is the hobgoblin of little minds.</p> <div id=“greeting”>Welcome, Jay Gatsby!</div> HTML Run Ruby
  8. h1 a { color: #333 font-size: 30px; margin-bottom: 30px; }

    h1 a span { color: #9c0; } #notes-module .title { color: #306e73; margin-bottom: 15px; } #footer h3 { color: #9c0; font-size: 15px; }
  9. <!DOCTYPE html> <head> <title>Foo</title> <link rel="stylesheet" href="reset.css"> <link rel="stylesheet" href="base.css">

    <link rel="stylesheet" href="widget.css"> </head> <body> <h1>Bar</h1> </body> </html>
  10. %ul %li %a{:href => “#”} Home %li.active %a{:href => “#”}

    About %li %a{:href => “#”} Work %li %a{:href => “#”} Contact Haml
  11. ul { padding-left: 0; } ul li { background: red;

    } ul li.current { background: maroon; } ul li a { color: white; } CSS
  12. $primary-color: red ul padding-left: 0 li background: $primary-color &:current background:

    darken($primary-color, 20%) a color: white &:hover color: green
  13. .entry { background: red; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;

    } .button { background: blue; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; } CSS
  14. %rounded-corners -webkit-border-radius: 15px -moz-border-radius: 15px border-radius: 15px .entry background: red

    @extend %rounded-corners .button background: blue @extend %rounded-corners
  15. .entry, .button { -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; }

    .entry { background: red; } .button { background: blue; } CSS
  16. .scss .sass • More like CSS • Benefits of Sass

    • Easily convert existing projects • Similar to LESS • Cleanest, most minimal syntax • Great to use with new projects • Go all the way style.scss 㱻 style.sass
  17. $.ajax({ context: $(‘form’), url: ‘http://foobar.baz’, dataType: ‘json’, done: function(data) {

    var $r = $(this).find(‘.response’); var $f = $(this).find(‘.form-wrap’); $r.find(‘h1’).html(data.status); $f.slideUp(function(){ $r.slideDown(); }); } }); JavaScript
  18. var happy = true; var knowIt = true; if (happy

    && knowIt) { clapHands(); } else { showIt(); } JavaScript
  19. function eat(food) { console.log(food + "nom nom nom"); } var

    food = ['stuffing', 'turkey', 'pie']; for (var i=0; i < food.length; i++) { eat(food[i]); }; // stuffing nom nom nom // turkey nom nom nom // pie nom nom nom JavaScript
  20. # Haml :javascript var a = 1; # Coffee a

    = 5 console a, window.a # You might assume 5, 5
  21. # Haml :javascript var a = 1; # Coffee ->

    JavaScript (function(){ var a; a = 5; console(a, window.a); })(); # 5, 1
  22. $.ajax context: $(‘form’) url: ‘http://foobar.baz’ dataType: ‘json’ done: (data) ->

    $r = $r = $(this).find ‘.response’ $f = $(this).find ‘.form-wrap’ $r.find(‘h1’).html data.status $f.slideUp -> $r.slideDown
  23. $.ajax({ context: $(‘form’), url: ‘http://foobar.baz’, dataType: ‘json’, done: function(data) {

    var $r = $(this).find(‘.response’); var $f = $(this).find(‘.form-wrap’); $r.find(‘h1’).html(data.status); $f.slideUp(function(){ $r.slideDown(); }); } }); JavaScript
  24. var happy = true; var knowIt = true; if (happy

    && knowIt) { clapHands(); } else { showIt(); } JavaScript
  25. for food in [‘stuffing’, ‘turkey', ‘pie’] console.log "#{food} nom nom

    nom" // stuffing nom nom nom // turkey nom nom nom // pie nom nom nom
  26. var food, _i, _len, _ref; _ref = ['stuffing', 'turkey', 'pie'];

    for (_i = 0, _len = _ref.length; _i < _len; _i++) { food = _ref[_i]; console.log("" + food + " nom nom nom"); } JavaScript
  27. meal = [‘stuffing’, ‘turkey', ‘pie’] for food in meal when

    food isnt ‘pie’ console.log "#{food} nom nom nom" // stuffing nom nom nom // turkey nom nom nom
  28. var food, meal, _i, _len; meal = ['stuffing', 'turkey', 'pie'];

    for (_i = 0, _len = meal.length; _i < _len; _i++){ food = meal[_i]; if (food !== 'pie') { console.log("" + food + " nom nom nom"); } } JavaScript
  29. # Haml $ haml input.haml output.html # Sass $ sass

    --watch app/sass:public/stylesheets # Coffee $ coffee --join project.js --compile src/*.coffee
  30. Git