Show the frontend some love - HAML, SASS and COMPASS - Presentation Transcript
Show the frontend some love
haml & sass & compass
26.05.2009
RailsWayCon
Jan Krutisch <jan@krutisch.de>
mindmatters GmbH & Co. KG
Dienstag, 26. Mai 2009
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
(disclaimer)
Dienstag, 26. Mai 2009
HAML
Dienstag, 26. Mai 2009
(X)HTML Abstraction
Markup Language
Dienstag, 26. Mai 2009
Just another template
language?
Dienstag, 26. Mai 2009
<em>
<% \"what's wrong
with erb or erubis?\"
%>
</em>
Dienstag, 26. Mai 2009
Nothing really.
Dienstag, 26. Mai 2009
Powerful.
Dienstag, 26. Mai 2009
Flexible.
Dienstag, 26. Mai 2009
Reasonably fast.
Dienstag, 26. Mai 2009
But!
Dienstag, 26. Mai 2009
1) Security
Dienstag, 26. Mai 2009
lam3 cøD3rZ, stupid
bastards, black
hatters
Dienstag, 26. Mai 2009
<% `rm -rf /` %>
Dienstag, 26. Mai 2009
2) Style/ Design
Dienstag, 26. Mai 2009
Too much logic in the
view!
Dienstag, 26. Mai 2009
Separation of
concerns violated!!
Dienstag, 26. Mai 2009
Millions of cute
kitties die !!!1!
image via http://cuteoverload.com
Dienstag, 26. Mai 2009
3) „Designers don‘t
understand code“
Dienstag, 26. Mai 2009
(Subtitle: WYSIWYG-Editors don‘t
understand code)
Dienstag, 26. Mai 2009
Let‘s fix it.
Dienstag, 26. Mai 2009
<b> {{ liquid }} </b>
Dienstag, 26. Mai 2009
Security!
Dienstag, 26. Mai 2009
Very limited
functionality and
access to data!
Dienstag, 26. Mai 2009
(Yeah, that's good)
Dienstag, 26. Mai 2009
OK, got that.
Dienstag, 26. Mai 2009
I don't care.
Dienstag, 26. Mai 2009
1) I am in full control
of my template code
Dienstag, 26. Mai 2009
2) I am a very
disciplined coder
Dienstag, 26. Mai 2009
3) I write all of my
HTML by myself
Dienstag, 26. Mai 2009
Different view
Dienstag, 26. Mai 2009
(x)HTML
=
XML
Dienstag, 26. Mai 2009
Tagsoup
Text
Dienstag, 26. Mai 2009
HTML-Tags =
Redundant
Dienstag, 26. Mai 2009
<div>
</div>
Dienstag, 26. Mai 2009
<div>
Re d
und
</div> an t
!
Dienstag, 26. Mai 2009
ERB = Too forgiving
Dienstag, 26. Mai 2009
(Too agnostic)
Dienstag, 26. Mai 2009
de x .e r b
in <%= render :partial => 'head' %>
...
<%= render :partial => 'foot' %>
e ad .e r b
_h
<body>
foo t .e r b
_
</body>
Dienstag, 26. Mai 2009
found via google search, source unknown
Dienstag, 26. Mai 2009
\"There must be
a better way\"™
Dienstag, 26. Mai 2009
Let's abstract.
Dienstag, 26. Mai 2009
HAML
Dienstag, 26. Mai 2009
Compact
Dienstag, 26. Mai 2009
No redundancies
Dienstag, 26. Mai 2009
Keeps the document
structure
Dienstag, 26. Mai 2009
Outputs beautiful code
Dienstag, 26. Mai 2009
installation as gem
&
rails plugin
Dienstag, 26. Mai 2009
> gem install haml
> cd rails_app
> haml --rails .
Dienstag, 26. Mai 2009
(Library/
commandline tool)
Dienstag, 26. Mai 2009
Tags!
Dienstag, 26. Mai 2009
%table
%tr
%td Hey there
Dienstag, 26. Mai 2009
%table
%tr
%td Hey there
Magic!
<table>
<tr>
<td>Hey there</td>
</tr>
</table>
Dienstag, 26. Mai 2009
%table
%tr
%td
Hey there
Magic!
<table>
<tr>
<td>
Hey there
</td>
</tr>
</table>
Dienstag, 26. Mai 2009
Syntactically
Awesome StyleSheets
Dienstag, 26. Mai 2009
Why?
Dienstag, 26. Mai 2009
found via google search, source unknown
Dienstag, 26. Mai 2009
Why?
Dienstag, 26. Mai 2009
No Variables/
Constants
Dienstag, 26. Mai 2009
No abstractions
Dienstag, 26. Mai 2009
No „real“ cascading
Dienstag, 26. Mai 2009
a few superfluous
characters
Dienstag, 26. Mai 2009
installation
Dienstag, 26. Mai 2009
(comes with haml)
Dienstag, 26. Mai 2009
stylesheets/sass/screen.sass
Magic!
stylesheets/screen.css
Dienstag, 26. Mai 2009
The basics
Dienstag, 26. Mai 2009
#main
:color #0f0
:width 300px
p
:color #030
Magic!
#main {
color: #0f0;
width: 300px; }
#main p {
color: #030; }
Dienstag, 26. Mai 2009
a l te
#main rna
color: #0f0 t i ve
syn
width: 300px
p tax
color: #030
Magic!
#main {
color: #0f0;
width: 300px; }
#main p {
color: #030; }
Dienstag, 26. Mai 2009
(
might be useful in migrational
situations
)
Dienstag, 26. Mai 2009
References
on parent
Dienstag, 26. Mai 2009
a
color: #0f0
&:hover
color: #0ff
Magic!
a {
color: #0f0; }
a:hover {
color: #0ff; }
Dienstag, 26. Mai 2009
.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}
e ss ed
c om pr
:
Dienstag, 26. Mai 2009
Rails made Web application development substantiall more
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. less
0 comments
Post a comment