show the frontend some love - haml, sass and compass

180
Show the frontend some love haml & sass & compass 26.05.2009 RailsWayCon Jan Krutisch <[email protected] > mindmatters GmbH & Co. KG Dienstag, 26. Mai 2009

Upload: janmindmatters

Post on 22-Nov-2014

3.081 views

Category:

Technology


1 download

DESCRIPTION

Rails made Web application development substantially more enjoyable. Surprisingly, even in Rails 2.3, there are some areas that still suck: Erb-Templates are the typical HTML/XML tag soup mess, CSS-Files are, well, CSS files. HAML and SASS are two technologies to fix this: HAML templates are concise and powerful, SASS makes writing CSS almost a fun experience. Be there or be width:20px height:20px.

TRANSCRIPT

Page 1: Show the frontend some love - HAML, SASS and COMPASS

Show the frontend some love

haml & sass & compass26.05.2009RailsWayConJan Krutisch <[email protected]>mindmatters GmbH & Co. KG

Dienstag, 26. Mai 2009

Page 2: Show the frontend some love - HAML, SASS and COMPASS

Jan Krutisch

‣ Rails since 2005

‣ Founder of rubyonrails-ug.de

‣Writer of a book and many articles

‣ Rails team captain @ mindmatters

‣ General all purpose geek

Dienstag, 26. Mai 2009

Page 3: Show the frontend some love - HAML, SASS and COMPASS

(disclaimer)

Dienstag, 26. Mai 2009

Page 4: Show the frontend some love - HAML, SASS and COMPASS

HAML

Dienstag, 26. Mai 2009

Page 5: Show the frontend some love - HAML, SASS and COMPASS

(X)HTML Abstraction Markup Language

Dienstag, 26. Mai 2009

Page 6: Show the frontend some love - HAML, SASS and COMPASS

Just another template language?

Dienstag, 26. Mai 2009

Page 7: Show the frontend some love - HAML, SASS and COMPASS

<em><% "what's wrong with erb or erubis?" %></em>

Dienstag, 26. Mai 2009

Page 8: Show the frontend some love - HAML, SASS and COMPASS

Nothing really.

Dienstag, 26. Mai 2009

Page 9: Show the frontend some love - HAML, SASS and COMPASS

Powerful.

Dienstag, 26. Mai 2009

Page 10: Show the frontend some love - HAML, SASS and COMPASS

Flexible.

Dienstag, 26. Mai 2009

Page 11: Show the frontend some love - HAML, SASS and COMPASS

Reasonably fast.

Dienstag, 26. Mai 2009

Page 12: Show the frontend some love - HAML, SASS and COMPASS

But!

Dienstag, 26. Mai 2009

Page 13: Show the frontend some love - HAML, SASS and COMPASS

1) Security

Dienstag, 26. Mai 2009

Page 14: Show the frontend some love - HAML, SASS and COMPASS

lam3 cøD3rZ, stupid bastards, black hatters

Dienstag, 26. Mai 2009

Page 15: Show the frontend some love - HAML, SASS and COMPASS

<% `rm -rf /` %>

Dienstag, 26. Mai 2009

Page 16: Show the frontend some love - HAML, SASS and COMPASS

2) Style/ Design

Dienstag, 26. Mai 2009

Page 17: Show the frontend some love - HAML, SASS and COMPASS

Too much logic in the view!

Dienstag, 26. Mai 2009

Page 18: Show the frontend some love - HAML, SASS and COMPASS

Separation of concerns violated!!

Dienstag, 26. Mai 2009

Page 19: Show the frontend some love - HAML, SASS and COMPASS

Millions of cute kitties die !!!1!

image via http://cuteoverload.comDienstag, 26. Mai 2009

Page 20: Show the frontend some love - HAML, SASS and COMPASS

3) „Designers don‘t understand code“

Dienstag, 26. Mai 2009

Page 21: Show the frontend some love - HAML, SASS and COMPASS

(Subtitle: WYSIWYG-Editors don‘t understand code)

Dienstag, 26. Mai 2009

Page 22: Show the frontend some love - HAML, SASS and COMPASS

Let‘s fix it.

Dienstag, 26. Mai 2009

Page 23: Show the frontend some love - HAML, SASS and COMPASS

<b> {{ liquid }} </b>

Dienstag, 26. Mai 2009

Page 24: Show the frontend some love - HAML, SASS and COMPASS

Security!

Dienstag, 26. Mai 2009

Page 25: Show the frontend some love - HAML, SASS and COMPASS

Very limited functionality and access to data!

Dienstag, 26. Mai 2009

Page 26: Show the frontend some love - HAML, SASS and COMPASS

(Yeah, that's good)

Dienstag, 26. Mai 2009

Page 27: Show the frontend some love - HAML, SASS and COMPASS

OK, got that.

Dienstag, 26. Mai 2009

Page 28: Show the frontend some love - HAML, SASS and COMPASS

I don't care.

Dienstag, 26. Mai 2009

Page 29: Show the frontend some love - HAML, SASS and COMPASS

1) I am in full control of my template code

Dienstag, 26. Mai 2009

Page 30: Show the frontend some love - HAML, SASS and COMPASS

2) I am a very disciplined coder

Dienstag, 26. Mai 2009

Page 31: Show the frontend some love - HAML, SASS and COMPASS

3) I write all of my HTML by myself

Dienstag, 26. Mai 2009

Page 32: Show the frontend some love - HAML, SASS and COMPASS

Different view

Dienstag, 26. Mai 2009

Page 33: Show the frontend some love - HAML, SASS and COMPASS

(x)HTML =XML

Dienstag, 26. Mai 2009

Page 34: Show the frontend some love - HAML, SASS and COMPASS

Text

Tagsoup

Dienstag, 26. Mai 2009

Page 35: Show the frontend some love - HAML, SASS and COMPASS

HTML-Tags = Redundant

Dienstag, 26. Mai 2009

Page 36: Show the frontend some love - HAML, SASS and COMPASS

<div>

</div>

Dienstag, 26. Mai 2009

Page 37: Show the frontend some love - HAML, SASS and COMPASS

<div>

</div>Redundant!

Dienstag, 26. Mai 2009

Page 38: Show the frontend some love - HAML, SASS and COMPASS

ERB = Too forgiving

Dienstag, 26. Mai 2009

Page 39: Show the frontend some love - HAML, SASS and COMPASS

(Too agnostic)

Dienstag, 26. Mai 2009

Page 40: Show the frontend some love - HAML, SASS and COMPASS

<%= render :partial => 'head' %>...<%= render :partial => 'foot' %>

<body>

</body>

index.erb

_head.erb

_foot.erb

Dienstag, 26. Mai 2009

Page 41: Show the frontend some love - HAML, SASS and COMPASS

found via google search, source unknownDienstag, 26. Mai 2009

Page 42: Show the frontend some love - HAML, SASS and COMPASS

"There must bea better way"™

Dienstag, 26. Mai 2009

Page 43: Show the frontend some love - HAML, SASS and COMPASS

Let's abstract.

Dienstag, 26. Mai 2009

Page 44: Show the frontend some love - HAML, SASS and COMPASS

HAML

Dienstag, 26. Mai 2009

Page 45: Show the frontend some love - HAML, SASS and COMPASS

Compact

Dienstag, 26. Mai 2009

Page 46: Show the frontend some love - HAML, SASS and COMPASS

No redundancies

Dienstag, 26. Mai 2009

Page 47: Show the frontend some love - HAML, SASS and COMPASS

Keeps the documentstructure

Dienstag, 26. Mai 2009

Page 48: Show the frontend some love - HAML, SASS and COMPASS

Outputs beautiful code

Dienstag, 26. Mai 2009

Page 49: Show the frontend some love - HAML, SASS and COMPASS

installation as gem& rails plugin

Dienstag, 26. Mai 2009

Page 50: Show the frontend some love - HAML, SASS and COMPASS

> gem install haml> cd rails_app> haml --rails .

Dienstag, 26. Mai 2009

Page 51: Show the frontend some love - HAML, SASS and COMPASS

(Library/commandline tool)

Dienstag, 26. Mai 2009

Page 52: Show the frontend some love - HAML, SASS and COMPASS

Tags!

Dienstag, 26. Mai 2009

Page 53: Show the frontend some love - HAML, SASS and COMPASS

%table %tr %td Hey there

Dienstag, 26. Mai 2009

Page 54: Show the frontend some love - HAML, SASS and COMPASS

%table %tr %td Hey there

Magic!

<table> <tr> <td>Hey there</td> </tr></table>

Dienstag, 26. Mai 2009

Page 55: Show the frontend some love - HAML, SASS and COMPASS

%table %tr %td Hey there

Magic!<table> <tr> <td> Hey there </td> </tr></table>

Dienstag, 26. Mai 2009

Page 56: Show the frontend some love - HAML, SASS and COMPASS

Self-closing tags

Dienstag, 26. Mai 2009

Page 57: Show the frontend some love - HAML, SASS and COMPASS

%foo/

<foo/>

Magic!

Dienstag, 26. Mai 2009

Page 58: Show the frontend some love - HAML, SASS and COMPASS

automagically for:

•meta

•img

•link

•script

•br

•hr

Dienstag, 26. Mai 2009

Page 59: Show the frontend some love - HAML, SASS and COMPASS

Whitespace control

Dienstag, 26. Mai 2009

Page 60: Show the frontend some love - HAML, SASS and COMPASS

(for those stoopid browser boogs)

Dienstag, 26. Mai 2009

Page 61: Show the frontend some love - HAML, SASS and COMPASS

%blockquote< %div Foo!

Magic!

<blockquote><div> Foo!</div></blockquote>

Dienstag, 26. Mai 2009

Page 62: Show the frontend some love - HAML, SASS and COMPASS

%img%img>%img

Magic!

<img /><img /><img />

Dienstag, 26. Mai 2009

Page 63: Show the frontend some love - HAML, SASS and COMPASS

Attributes!

Dienstag, 26. Mai 2009

Page 64: Show the frontend some love - HAML, SASS and COMPASS

%head{ :name => "doc_head" } %script{ 'type' => "text/" + "javascript", :src => "javascripts/script_#{2 + 7}" }

<head name='doc_head'> <script src='/docs/rdoc/javascripts/script_9' type='text/javascript'> </script></head>

Magic!

Dienstag, 26. Mai 2009

Page 65: Show the frontend some love - HAML, SASS and COMPASS

Attribute helpers

Dienstag, 26. Mai 2009

Page 66: Show the frontend some love - HAML, SASS and COMPASS

def html_attrs(lang = 'en-US') { :xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => lang, :lang => lang }end

Dienstag, 26. Mai 2009

Page 67: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<html lang='de-DE' xml:lang='de-DE' xmlns='http://www.w3.org/1999/xhtml'></html>

%html{html_attrs(lang = 'de-DE')}

Dienstag, 26. Mai 2009

Page 68: Show the frontend some love - HAML, SASS and COMPASS

Special case:

Dienstag, 26. Mai 2009

Page 69: Show the frontend some love - HAML, SASS and COMPASS

IDs & classes

Dienstag, 26. Mai 2009

Page 70: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<div id='aye_dee'> <div class='klazz'> Aha! </div></div>

#aye_dee .klazz Aha!

Dienstag, 26. Mai 2009

Page 71: Show the frontend some love - HAML, SASS and COMPASS

Ruby!

Dienstag, 26. Mai 2009

Page 72: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p>yay</p>

%p= "Yay".downcase

Dienstag, 26. Mai 2009

Page 73: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p>&lt;b&gt;yay&lt;/b&gt;</p>

%p&= "<b>Yay</b>".downcase

Dienstag, 26. Mai 2009

Page 74: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p><b>yay</b></p>

%p!= "<b>Yay</b>".downcase

Dienstag, 26. Mai 2009

Page 75: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p><b>yay</b></p>

%p= "<b>Yay</b>".downcase

Dienstag, 26. Mai 2009

Page 76: Show the frontend some love - HAML, SASS and COMPASS

Magic!

%p= "<b>Yay</b>".downcase

<p>&lt;b&gt;yay&lt;/b&gt;</p>

Dienstag, 26. Mai 2009

Page 77: Show the frontend some love - HAML, SASS and COMPASS

:escape_html

Dienstag, 26. Mai 2009

Page 78: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p>120231373274987476 Followers</p>

%p== #{followers} Followers

Dienstag, 26. Mai 2009

Page 79: Show the frontend some love - HAML, SASS and COMPASS

(same rules apply)

Dienstag, 26. Mai 2009

Page 80: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<pre>yay&#x000A;hey</pre>

%pre~ "Yay\nHey".downcase

Dienstag, 26. Mai 2009

Page 81: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<p>one</p><p>two</p><p>three</p>

%ul - %w{one two three}.each do |word| %li= word

Dienstag, 26. Mai 2009

Page 82: Show the frontend some love - HAML, SASS and COMPASS

Auto ID‘s and classes

Dienstag, 26. Mai 2009

Page 83: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<ul> <li class='string' id='string_2970900'>foo</li> <li class='string' id='string_2970890'>bar</li></ul>

%ul - ['foo', 'bar'].each do |el| %li[el]= el

Dienstag, 26. Mai 2009

Page 84: Show the frontend some love - HAML, SASS and COMPASS

Filters

Dienstag, 26. Mai 2009

Page 85: Show the frontend some love - HAML, SASS and COMPASS

Magic!

<h1>Header</h1>

<p>Hello <em>world</em></p>

:textile h1. Header Hello _world_

Dienstag, 26. Mai 2009

Page 86: Show the frontend some love - HAML, SASS and COMPASS

Available Filters

‣ plain

‣ javascript

‣ escaped

‣ ruby

‣ preserve

‣ erb

‣ sass‣ textile‣markdown‣maruku‣ roll yer own

Dienstag, 26. Mai 2009

Page 87: Show the frontend some love - HAML, SASS and COMPASS

Comments

Dienstag, 26. Mai 2009

Page 88: Show the frontend some love - HAML, SASS and COMPASS

Magic!

/ This is a comment

<!-- This is a comment -->

Dienstag, 26. Mai 2009

Page 89: Show the frontend some love - HAML, SASS and COMPASS

Magic!<!--[if IE]> <a href="http://www.getfirefox.com/"> Get Firefox! </a> <![endif]-->

/[if IE] %a{ :href => 'http://www.mozilla.com/en-US/firefox/' } %h1 Get Firefox!

Dienstag, 26. Mai 2009

Page 90: Show the frontend some love - HAML, SASS and COMPASS

-# A silent comment

Dienstag, 26. Mai 2009

Page 91: Show the frontend some love - HAML, SASS and COMPASS

Magic!

-# A silent comment

Dienstag, 26. Mai 2009

Page 92: Show the frontend some love - HAML, SASS and COMPASS

But wait, there's more!

Dienstag, 26. Mai 2009

Page 94: Show the frontend some love - HAML, SASS and COMPASS

F.A.Q.

Dienstag, 26. Mai 2009

Page 95: Show the frontend some love - HAML, SASS and COMPASS

Performance

Dienstag, 26. Mai 2009

Page 96: Show the frontend some love - HAML, SASS and COMPASS

Usage without rails

Dienstag, 26. Mai 2009

Page 97: Show the frontend some love - HAML, SASS and COMPASS

require 'rubygems'require 'haml'template = open('simple.haml').readengine = Haml::Engine.new(template)puts engine.render

Dienstag, 26. Mai 2009

Page 98: Show the frontend some love - HAML, SASS and COMPASS

template = <<END%h1= fooENDobj = Object.newengine = Haml::Engine.new(template).def_method(obj, :render, :foo)puts obj.render(:foo => 'bar')

Dienstag, 26. Mai 2009

Page 99: Show the frontend some love - HAML, SASS and COMPASS

Migration

Dienstag, 26. Mai 2009

Page 100: Show the frontend some love - HAML, SASS and COMPASS

SASS

Dienstag, 26. Mai 2009

Page 101: Show the frontend some love - HAML, SASS and COMPASS

Syntactically Awesome StyleSheets

Dienstag, 26. Mai 2009

Page 102: Show the frontend some love - HAML, SASS and COMPASS

Why?

Dienstag, 26. Mai 2009

Page 103: Show the frontend some love - HAML, SASS and COMPASS

found via google search, source unknownDienstag, 26. Mai 2009

Page 104: Show the frontend some love - HAML, SASS and COMPASS

Why?

Dienstag, 26. Mai 2009

Page 105: Show the frontend some love - HAML, SASS and COMPASS

No Variables/ Constants

Dienstag, 26. Mai 2009

Page 106: Show the frontend some love - HAML, SASS and COMPASS

No abstractions

Dienstag, 26. Mai 2009

Page 107: Show the frontend some love - HAML, SASS and COMPASS

No „real“ cascading

Dienstag, 26. Mai 2009

Page 108: Show the frontend some love - HAML, SASS and COMPASS

a few superfluous characters

Dienstag, 26. Mai 2009

Page 109: Show the frontend some love - HAML, SASS and COMPASS

installation

Dienstag, 26. Mai 2009

Page 110: Show the frontend some love - HAML, SASS and COMPASS

(comes with haml)

Dienstag, 26. Mai 2009

Page 111: Show the frontend some love - HAML, SASS and COMPASS

stylesheets/sass/screen.sass

stylesheets/screen.css

Magic!

Dienstag, 26. Mai 2009

Page 112: Show the frontend some love - HAML, SASS and COMPASS

The basics

Dienstag, 26. Mai 2009

Page 113: Show the frontend some love - HAML, SASS and COMPASS

Magic!

#main { color: #0f0; width: 300px; } #main p { color: #030; }

#main :color #0f0 :width 300px p :color #030

Dienstag, 26. Mai 2009

Page 114: Show the frontend some love - HAML, SASS and COMPASS

#main { color: #0f0; width: 300px; } #main p { color: #030; }

Magic!

alternative syntax

#main color: #0f0 width: 300px p color: #030

Dienstag, 26. Mai 2009

Page 115: Show the frontend some love - HAML, SASS and COMPASS

(might be useful in migrational situations)

Dienstag, 26. Mai 2009

Page 116: Show the frontend some love - HAML, SASS and COMPASS

Referenceson parent

Dienstag, 26. Mai 2009

Page 117: Show the frontend some love - HAML, SASS and COMPASS

a { color: #0f0; } a:hover { color: #0ff; }

Magic!

a color: #0f0 &:hover color: #0ff

Dienstag, 26. Mai 2009

Page 118: Show the frontend some love - HAML, SASS and COMPASS

#sidebar { float: left; margin-left: 20%; } .ie6 #sidebar { margin-left: 40%; }

Magic!

#sidebar :float left :margin-left 20% .ie6 & :margin-left 40%

Dienstag, 26. Mai 2009

Page 119: Show the frontend some love - HAML, SASS and COMPASS

Compoundstyles

Dienstag, 26. Mai 2009

Page 120: Show the frontend some love - HAML, SASS and COMPASS

.black-border { border-color: #000; border-width: 2px; border-style: solid; }

Magic!

.black-border :border :color #000 :width 2px :style solid

Dienstag, 26. Mai 2009

Page 121: Show the frontend some love - HAML, SASS and COMPASS

Constants

Dienstag, 26. Mai 2009

Page 122: Show the frontend some love - HAML, SASS and COMPASS

!bg_color = #002244body :color = !bg_color

body { background-color: #002244; }

Magic!

Dienstag, 26. Mai 2009

Page 123: Show the frontend some love - HAML, SASS and COMPASS

!bg_color = #002244body :color = !bg_color

body { background-color: #002244; }

Magic!

Achtung!

Dienstag, 26. Mai 2009

Page 124: Show the frontend some love - HAML, SASS and COMPASS

Calculations

Dienstag, 26. Mai 2009

Page 125: Show the frontend some love - HAML, SASS and COMPASS

body { background-color: #022446; }

Magic!

!bg_color = #002244body :color = !bg_color + #020202

Dienstag, 26. Mai 2009

Page 126: Show the frontend some love - HAML, SASS and COMPASS

Mixins

Dienstag, 26. Mai 2009

Page 127: Show the frontend some love - HAML, SASS and COMPASS

Magic!#main { border: 1px solid black; padding: 5px; }

=standard-border :border 1px solid black#main +standard-border :padding 5px

Dienstag, 26. Mai 2009

Page 128: Show the frontend some love - HAML, SASS and COMPASS

@import

Dienstag, 26. Mai 2009

Page 129: Show the frontend some love - HAML, SASS and COMPASS

Output Styles

Dienstag, 26. Mai 2009

Page 130: Show the frontend some love - HAML, SASS and COMPASS

:compressed

.box{border-top:1px solid black;border-bottom:5px solid black}body{background-color:#002244}#main{color:lime;p-background-color:lime;p-color:#000000}#main{border:1px solid black;padding:5px}

Dienstag, 26. Mai 2009

Page 131: Show the frontend some love - HAML, SASS and COMPASS

A look at SASS Edge

Dienstag, 26. Mai 2009

Page 132: Show the frontend some love - HAML, SASS and COMPASS

Mixin arguments

Dienstag, 26. Mai 2009

Page 133: Show the frontend some love - HAML, SASS and COMPASS

=border(!color = #000) :border 1px solid :color = !color#foo +border(#fea)

Dienstag, 26. Mai 2009

Page 134: Show the frontend some love - HAML, SASS and COMPASS

Control structures

Dienstag, 26. Mai 2009

Page 135: Show the frontend some love - HAML, SASS and COMPASS

@for !n from 1 through 6 h#{!n} :padding 0 :margin 0

Dienstag, 26. Mai 2009

Page 136: Show the frontend some love - HAML, SASS and COMPASS

!shall_we = false

@if !shall_we body :background-color yellow@else body :display none

Dienstag, 26. Mai 2009

Page 137: Show the frontend some love - HAML, SASS and COMPASS

F.A.Q.

Dienstag, 26. Mai 2009

Page 138: Show the frontend some love - HAML, SASS and COMPASS

Performance

Dienstag, 26. Mai 2009

Page 139: Show the frontend some love - HAML, SASS and COMPASS

File caching

Dienstag, 26. Mai 2009

Page 140: Show the frontend some love - HAML, SASS and COMPASS

Reload behaviour

Dienstag, 26. Mai 2009

Page 141: Show the frontend some love - HAML, SASS and COMPASS

Usage without rails

Dienstag, 26. Mai 2009

Page 142: Show the frontend some love - HAML, SASS and COMPASS

require 'rubygems'require 'sass'

template = open('simple.sass').readsass_engine = Sass::Engine.new(template)output = sass_engine.renderputs output

Dienstag, 26. Mai 2009

Page 143: Show the frontend some love - HAML, SASS and COMPASS

COMPASS

Dienstag, 26. Mai 2009

Page 144: Show the frontend some love - HAML, SASS and COMPASS

CSS meta framework

Dienstag, 26. Mai 2009

Page 145: Show the frontend some love - HAML, SASS and COMPASS

CSS frameworks

•Blueprint

•YUI-Grids

•960.gs

•YAML

Dienstag, 26. Mai 2009

Page 146: Show the frontend some love - HAML, SASS and COMPASS

COMPASS-Module

•Reset

•Utilities

•Layout

Dienstag, 26. Mai 2009

Page 147: Show the frontend some love - HAML, SASS and COMPASS

Installation

Dienstag, 26. Mai 2009

Page 148: Show the frontend some love - HAML, SASS and COMPASS

COMPASS requires HAML/SASS edge

Dienstag, 26. Mai 2009

Page 149: Show the frontend some love - HAML, SASS and COMPASS

> git clone git://github.com/nex3/haml.git> cd haml> sudo rake install

> gem sources --add http://gems.github.com/ > sudo gem install chriseppstein-compass

Dienstag, 26. Mai 2009

Page 150: Show the frontend some love - HAML, SASS and COMPASS

Rails-Integration

Dienstag, 26. Mai 2009

Page 151: Show the frontend some love - HAML, SASS and COMPASS

> compass --rails .

Dienstag, 26. Mai 2009

Page 152: Show the frontend some love - HAML, SASS and COMPASS

app/stylesheets/foo.sass

public/stylesheets/compiled/foo.css

Magic!

Dienstag, 26. Mai 2009

Page 153: Show the frontend some love - HAML, SASS and COMPASS

Example (Blueprint)

Dienstag, 26. Mai 2009

Page 154: Show the frontend some love - HAML, SASS and COMPASS

artist_header logo_header

bodybody

footerfooter

header

Dienstag, 26. Mai 2009

Page 155: Show the frontend some love - HAML, SASS and COMPASS

!!! Strict%html{html_attrs('de-de')} %head = stylesheet_link_tag 'compiled/screen.css' /[if IE] = stylesheet_link_tag 'compiled/ie.css' %body .container #header.span-24 #artist_header.span-6 %h1 Foo #logo_header.span-18.last %h2 Bar #body.span-24 = yield #footer.span-24

Dienstag, 26. Mai 2009

Page 156: Show the frontend some love - HAML, SASS and COMPASS

!!! Strict%html{html_attrs('de-de')} %head = stylesheet_link_tag 'compiled/screen.css' /[if IE] = stylesheet_link_tag 'compiled/ie.css' %body #container #header #artist_header %h1 Foo #logo_header %h2 Bar #body = yield #footer

Dienstag, 26. Mai 2009

Page 157: Show the frontend some love - HAML, SASS and COMPASS

@import compass/reset.sass@import blueprint/modules/grid.sass

#container +container

#header +column(24, true) #artist_header +column(6)

#logo_header +column(18, true)

#body +column(24, true) #footer +column(24, true)

Dienstag, 26. Mai 2009

Page 158: Show the frontend some love - HAML, SASS and COMPASS

Flexible grid definitions

Dienstag, 26. Mai 2009

Page 159: Show the frontend some love - HAML, SASS and COMPASS

(try that, blueprint!)

Dienstag, 26. Mai 2009

Page 160: Show the frontend some love - HAML, SASS and COMPASS

@import compass/reset.sass@import blueprint/modules/grid.sass

!blueprint_grid_columns = 10!blueprint_grid_width = 60px!blueprint_grid_margin = 10px

#container +container

#header +column(24, true) #artist_header +column(6)

#logo_header +column(18, true)

#body +column(24, true) #footer +column(24, true)

Dienstag, 26. Mai 2009

Page 161: Show the frontend some love - HAML, SASS and COMPASS

F.A.Q.

Dienstag, 26. Mai 2009

Page 162: Show the frontend some love - HAML, SASS and COMPASS

Duplication in generated code

Dienstag, 26. Mai 2009

Page 163: Show the frontend some love - HAML, SASS and COMPASS

Short answer: Yes

Dienstag, 26. Mai 2009

Page 164: Show the frontend some love - HAML, SASS and COMPASS

Compatibility between frameworks

Dienstag, 26. Mai 2009

Page 165: Show the frontend some love - HAML, SASS and COMPASS

work in progress

Dienstag, 26. Mai 2009

Page 166: Show the frontend some love - HAML, SASS and COMPASS

questions?

Dienstag, 26. Mai 2009

Page 167: Show the frontend some love - HAML, SASS and COMPASS

SUM()

Dienstag, 26. Mai 2009

Page 168: Show the frontend some love - HAML, SASS and COMPASS

Me likes.

Dienstag, 26. Mai 2009

Page 169: Show the frontend some love - HAML, SASS and COMPASS

Very DRY.+Dienstag, 26. Mai 2009

Page 170: Show the frontend some love - HAML, SASS and COMPASS

Very readable.+Dienstag, 26. Mai 2009

Page 171: Show the frontend some love - HAML, SASS and COMPASS

Faster.(to develop)

+Dienstag, 26. Mai 2009

Page 172: Show the frontend some love - HAML, SASS and COMPASS

Catches structural errors early.

+Dienstag, 26. Mai 2009

Page 173: Show the frontend some love - HAML, SASS and COMPASS

Needs a willing environment

-

Dienstag, 26. Mai 2009

Page 174: Show the frontend some love - HAML, SASS and COMPASS

(Not HTML4dummies compliant)

-

Dienstag, 26. Mai 2009

Page 175: Show the frontend some love - HAML, SASS and COMPASS

You‘ll miss a few tricks

-

Dienstag, 26. Mai 2009

Page 176: Show the frontend some love - HAML, SASS and COMPASS

(Like CSSEdit)-Dienstag, 26. Mai 2009

Page 177: Show the frontend some love - HAML, SASS and COMPASS

You‘ll get new tricks+Dienstag, 26. Mai 2009

Page 178: Show the frontend some love - HAML, SASS and COMPASS

Like having a css framework essentially „for free“

+

Dienstag, 26. Mai 2009

Page 179: Show the frontend some love - HAML, SASS and COMPASS

discuss.

Dienstag, 26. Mai 2009

Page 180: Show the frontend some love - HAML, SASS and COMPASS

http://twitter.com/halfbyte

http://github.com/halfbyte

http://www.flickr.com/photos/jankrutisch/

thanks.

Dienstag, 26. Mai 2009