SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Haml, Sass, Compass

         BĂĄcsi LĂĄszlĂł
     bacsi.laszlo@virgo.hu
Haml

‱   Sablonozó motor
‱   HTML-nĂ©l egyszerƱbb Ă©s ĂĄtlĂĄthatĂłbb
‱   Nincs redundancia (DRY)
‱   Szemantikus kĂłd, szĂ©p kimenet
Sass

‱   Haml szerƱ szintaxis StyleSheet-ekhez
‱   Egymásba ágyazott kiválasztók
‱   Nincs redundancia (DRY)
‱   Konstansok Ă©s egyszerƱ mƱveletek
‱   Újrahasználató CSS mixinek
‱   A leĂ­rĂł kĂłd szĂ©p kellene legyen

‱   A leĂ­rĂł kĂłd nem kellene ismĂ©telje
    magĂĄt

‱   A leíró kód jól indentált kellene
    legyen

‱   A struktĂșra tisztĂĄn lĂĄthatĂł kellene
    legyen
Haml
Alapok
Haml                                            HTML
#content                                        <div id='content'>
  .left.column                                    <div class='left column'>
    %h2 Welcome to our site!                        <h2>Welcome to our site!</h2>
    %p= print_information                           <p>
  .right.column= render :partial => quot;sidebarquot;          <%= print_information %>
                                                    </p>
                                                  </div>
                                                  <div class=quot;right columnquot;>
                                                    <%= render :partial => quot;sidebarquot; %>
                                                  </div>
                                                </div>
Alapok
Haml                                 HTML
%tagname{:attr => 'value'} content   <tagname attr=quot;valuequot;>content</tagname>
%tagname#id.class content            <tagname id=quot;idquot; class=quot;classquot;>content</
                                     tagname>

%tagname                             <tagname>
  %innerTag                            <innerTag/>
  and some content                     and some content
                                     </tagname>

#company Virgo                       <div id=quot;companyquot;>Virgo</div>

.employee BĂĄcsi LĂĄszlĂł               <div class=quot;employeequot;>BĂĄcsi LĂĄszlĂł</div>
-, = – Ruby kód beágyazás
Rubys Haml kĂłd                                GenerĂĄlt HTML
%dl                                           <dl>
  - now = DateTime.now                          <dt>DĂĄtum Ă©s idƑ:</dt>
  %dt DĂĄtum Ă©s idƑ:                             <dd>
  %dd                                              Boldog Ășj Ă©vet!
    - if now > DateTime.parse('2008-12-31')     </dd>
      Boldog Ășj Ă©vet!                         </dl>
    - else
      = now.to_s                              <dl>
                                                <dt>DĂĄtum Ă©s idƑ:</dt>
                                                <dd>
                                                   2008-12-30T12:31:45+01:00
                                                </dd>
                                              </dl>

- @gems = %w{rails haml compass}              <ul id='gems'>
%ul#gems                                        <li class='gem'>rails</li>
  - @gems.each do |gem|                         <li class='gem'>haml</li>
    %li.gem= gem                                <li class='gem'>compass</li>
                                              </ul>
{} – AttribĂștumok
Haml                                            HTML
%bar/                                           <bar/>

%script{:type => 'text/' + 'javascript', |      <script src='/js/locale.hu.js' type='text/
        :src => quot;/js/locale.#{@lang}.jsquot;} |     javascript'></script>

# ruby helperek
def defaults
  {:type => 'checkbox', :value => '1'}
end

def override
  {:type => 'radio'}
end

                                                <input type=quot;radioquot; value=quot;1quot;
%input{defaults, override, :selected => true}
                                                selected=quot;selectedquot;/>
[] – id Ă©s class generĂĄlĂĄs
Haml                      HTML
- @user = User.find(42)   <div id=quot;current_user_42quot;
%div[@user, :current]     class=quot;current_userquot;>
  %span[7] 7.               <span id=quot;fixnum_7quot; class=quot;fixnumquot;>7.</span>
  KĂșl, mi?                  KĂșl, mi?
                          </div>
==, &=, !=, -# – Ruby inputok
Haml                                      HTML
- name = quot;<b>Haml</b>quot;

= quot;Hello, #{name}!quot;                       Hello,   <b>Haml</b>!
== Hello, #{name}!                        Hello,   <b>Haml</b>!
&= quot;Hello, #{name}!quot;                      Hello,   &lt;b&gt;Haml&lt;/b&gt;!
!= quot;Hello, #{name}!quot;                      Hello,   <b>Haml</b>!
-# Ez itt egy komment, ami nem kerĂŒl ki
!!! – xml Ă©s doctype
Haml                 HTML
!!! XML              <?xml version='1.0' encoding='utf-8' ?>
!!! XML iso-8859-2   <?xml version='1.0' encoding='iso-8859-2' ?>
!!! Strict           <!DOCTYPE html PUBLIC quot;-//W3C//DTD XHTML 1.0
                     Strict//ENquot; quot;http://www.w3.org/TR/xhtml1/DTD/
                     xhtml1-strict.dtdquot;>
/ – Kommentek
Haml                                           HTML
- name = quot;Calvinquot;                              <div class='user'>
.user                                            <!-- Ez itt a neve -->
  / Ez itt a neve                                Calvin
  = name                                       </div>

/                                              <!--
    Ezt a kódot most egyelƑre nem rakjuk ki,     Ezt a kódot most egyelƑre nem rakjuk ki,
    mert problĂ©mĂĄk lehetnek belƑle.              mert problĂ©mĂĄk lehetnek belƑle.
    %script                                      <script>
      evil();                                       evil();
                                                 </script>
                                               -->

                                               <!--[if IE]>
/[if IE]
                                                 <link href='/css/ie.css' rel='stylesheet'
  %link{:href => quot;/css/ie.cssquot;, |
                                               type='text/css' />
         :rel => quot;stylesheetquot;, |
                                               <![endif]-->
         :type => quot;text/cssquot;}   |
:markdown – Filterek
Haml                            HTML
%div                            <div>
  :markdown                       <h1>Hello <em>World</em>!</h1>
     # Hello *World*!           </div>

%Content{:type => 'html'}       <Content type='html'>
  :cdata                          <![CDATA[
    <p>iWiW gadzsett</p>              <p>iWiW gadzsett</p>
                                  ]]>
                                </Content>

# sajĂĄt filter
module Haml::Filters::Upcaser
  include Haml::Filters::Base

  def render(text)
    text.upcase
  end
end

%h1                             <h1>
  :upcaser                        FIGYELEM, FIGYELEM!
    figyelem, figyelem!         </h1>
Sass
Alapok
Sass                           CSS
#box                           #box {
  margin: 10px                   margin: 10px;
  color: #ff0                    color: #ff0; }

#box                           #box {
  :margin 10px                   margin: 10px;
  :color #ff0                    color: #ff0; }

#box                           #box {
  :margin 10px                   margin: 10px;
  :color #ff0                    color: #ff0; }
  h1                             #box h1 {
     :font-size 0.8em              font-size: 0.8em; }
     a                             #box h1 a {
       :text-decoration none          text-decoration: none; }
Konstansok
Sass                                      CSS
!highlight = #ccb
!normal_text = 12px

body                                      body {
  :font-size = !normal_text                 font-size: 12px; }

em                                        em {
  :background-color = !highlight            background-color: #ccccbb; }

em.important                              em.important {
  :background-color = !highlight + #333     background-color: #ffffee;
  :font-size = 1.5 * !normal_text           font-size: 18px; }
Kommentek
Sass                                            CSS
/* Fejléc                                       /* Fejléc */
#header                                         #header {
  :font-size 1em                                  font-size: 1em; }

// Ez itt meg bele se kerĂŒl a generĂĄlt css-be
                                                /*
/*                                               * Ez egy többsoros
  Ez egy többsoros                               * quot;hangosquot; komment */
  quot;hangosquot; komment                              #footer {
#footer                                            font-size: 0.8em; }
  :font-size 0.8em

//
  Ez pedig szintén több soros,
  de nem kerĂŒl be a css kĂłdba
Bonyolultabb kombinĂĄciĂłk
Sass                      CSS
#main                     #main {
  :width 600px              width: 600px; }
  p, div                    #main p, #main div {
    :font-size 1.5em          font-size: 1.5em; }
    a                         #main p a, #main div a {
      :font-weight bold         font-weight: bold; }
      img                       #main p a img, #main div a img {
         :border 0                border: 0; }
SzĂŒlƑ vĂĄlasztĂł
Sass                              CSS
a                                 a{
    :color #00f                    color: #00f; }
    img                            a img {
      :border 0                      border: 0; }
    &.disabled                     a.disabled {
      :color #444                    color: #444; }
    &:link, &:active, &:visited    a:link, a:active, a:visited {
      :text-decoration none          text-decoration: none; }
    &:hover                        a:hover {
      :color #0ff                    color: #0ff; }
      img                            a:hover img {
        :border 2px solid #0ff         border: 2px solid #0ff; }
        body.admin &                   body.admin a:hover img {
          :border-color #f00             border-color: #f00; }
AttribĂștum namespace
Sass                              CSS
em                                em {
  :font                             font-size: 14px;
    :size 14px                      font-style: italic;
    :style italic                   font-family: Verdana, sans-serif; }
    :family Verdana, sans-serif
Újrafelhasználható kódok
Sass                      CSS
=clearfix                 ul.images {
  display: inline-block     display: inline-block; }
  &:after                   ul.images:after {
    content: quot;.quot;              content: quot;.quot;;
    display: block            display: block;
    height: 0                 height: 0;
    clear: both               clear: both;
    visibility: hidden        visibility: hidden; }
  * html &                  * html ul.images {
    height: 1px               height: 1px; }

ul.images
  +clearfix

                          p strong {
=larger-text                font-size: 1.2em; }
  :font-size 1.2em          p strong em {
p strong                      font-size: 1.2em; }
  +larger-text                p strong em .important {
  em                            font-size: 1.2em; }
     +larger-text
     .important
       +larger-text
Paraméterek és kombinålås
Sass                            CSS
=hanging-indent(!indentation)   p{
  text-indent = -!indentation    text-indent: -12px;
  padding-left = !indentation    padding-left: 12px; }

p
    +hanging-indent(12px)

=float-container                #items {
  +clearfix                       display: inline-block; }
  div                             #items:after {
    float: left                     content: quot;.quot;;
  .clear                            display: block;
    clear: both                     height: 0;
                                    clear: both;
#items                              visibility: hidden; }
  +float-container                * html #items {
                                    height: 1px; }
                                  #items div {
                                    float: left; }
                                  #items .clear {
                                    clear: both; }
@import
Sass                                   CSS
// classes.sass                        .highlight {
.highlight                               color: #ffe; }
  :color #ffe
                                       @import url(zen.css);
@import classes.sass                   @font-face {
                                         font-family: quot;Bitstream Vera Sansquot;;
@import zen.css                          src: url(http://foo.bar/bvs); }

// egyéb kukacokat is békénhagyja
@font-face
  :font-family quot;Bitstream Vera Sansquot;
  :src url(http://foo.bar/bvs)
Compass
Mi az a Compass?
‱   Egy Sass-re Ă©pĂŒlƑ framework
‱   Több ismert CSS framework-öt
    tåmogat Sass mixinek segítségével
    (Blueprint, YUI, 960.gs)
‱   Sok hasznos CSS mintát ad (reset,
    clearïŹx, no-bullets, horizontal-list,
    inline-list, inline-block, tag-cloud,
    alternating-rows-and-columns, stb.)
screen.sass (példa)
@import   blueprint/screen.sass
@import   blueprint/modules/grid.sass
@import   blueprint/modules/colors.sass
@import   compass/reset.sass
@import   compass/utilities.sass

body.blueprint
  +blueprint-typography
  .container
    +container
  #header
    +column(24)
    h1
       :float left
    #site-actions
       :float right
       +horizontal-list
       +no-bullets
  #main-content
    +column(18)
    +colborder
  #sidebar
    +column(5,true)
  #footer
    +column(24)
KompatibilitĂĄs
Akkor ERB szemét?
‱   A kĂŒlönbözƑ template-ek megĂ©lnek
    egymĂĄs mellett
‱   show.html.erb, show.html.haml,
    feed.xml.builder, feed.xml.haml
‱   Generált ERB kódok maradhatnak,
    amĂ­g ĂĄt nem kell Ă­rni
‱   Akár kombinálhatóak is
És a CSS

‱   Sass nagyon hasonlít CSS-hez
‱   Csak kiszeded a {} Ă©s ; karaktereket Ă©s
    valid Sass
‱   html2haml, css2sass
KonïŹgurĂĄlhatĂłsĂĄg


‱   :escape_html, :supress_eval,
    :autoclose, :preserve, stb.
‱   :style, :attribute_syntax
Telepítés
$   git clone git://github.com/nex3/haml.git
$   cd haml && rake install; cd ..
$   git clone git://github.com/chriseppstein/compass.git
$   cd compass && rake install; cd ..
$   cd /my/cool/rails/project
$   haml --rails .
$   compass --rails -f blueprint
Compass recommends that you keep your stylesheets in app/stylesheets/
instead of the Sass default location of public/stylesheets/sass/.
Is this OK? (Y/n) y

Compass recommends that you keep your compiled css in public/stylesheets/
compiled/ instead the Sass default of public/stylesheets/.
However, if you're exclusively using Sass, then public/stylesheets/ is
recommended.
Emit compiled stylesheets to public/stylesheets/compiled? (Y/n) n
directory app/stylesheets/
   create app/stylesheets/screen.sass
   create app/stylesheets/print.sass
   create app/stylesheets/ie.sass
   create config/initializers/compass.rb
   create app/views/layouts/application.html.haml
TovĂĄbbi infĂłk

‱   http://haml.hamptoncatlin.com/

‱   http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml.html

‱   http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html

‱   http://wiki.github.com/chriseppstein/compass/

‱   http://acts-as-architect.blogspot.com/2008/11/compass-
    primer.html

‱   http://www.blueprintcss.org/

Weitere Àhnliche Inhalte

Was ist angesagt?

Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?brynary
 
El dĂ­a grande de los rodriguez
El dĂ­a grande de los rodriguezEl dĂ­a grande de los rodriguez
El dĂ­a grande de los rodriguezyumac00
 
Changing Template Engine
Changing Template EngineChanging Template Engine
Changing Template EngineTakatsugu Shigeta
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript BasicKang-min Liu
 
Critical Rendering Path
Critical Rendering PathCritical Rendering Path
Critical Rendering PathBarbaraFellner1
 
Script iklan cse
Script iklan cseScript iklan cse
Script iklan cseAhmad Kartiwa
 
Meetup django common_problems(1)
Meetup django common_problems(1)Meetup django common_problems(1)
Meetup django common_problems(1)Eric Satterwhite
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Nur Fadli Utomo
 
Handout6 html frames
Handout6 html framesHandout6 html frames
Handout6 html framesNadine Guevarra
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsKaelig Deloumeau-Prigent
 
WordPress theme translation
WordPress theme translationWordPress theme translation
WordPress theme translationYoav Farhi
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodJeremy Kendall
 
Stylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStartStylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStartScott DeLoach
 
CSS Layout Tutorial
CSS Layout TutorialCSS Layout Tutorial
CSS Layout Tutorialhstryk
 

Was ist angesagt? (20)

Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
El dĂ­a grande de los rodriguez
El dĂ­a grande de los rodriguezEl dĂ­a grande de los rodriguez
El dĂ­a grande de los rodriguez
 
Changing Template Engine
Changing Template EngineChanging Template Engine
Changing Template Engine
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Critical Rendering Path
Critical Rendering PathCritical Rendering Path
Critical Rendering Path
 
ColdFusion ORM
ColdFusion ORMColdFusion ORM
ColdFusion ORM
 
Script iklan cse
Script iklan cseScript iklan cse
Script iklan cse
 
Tfbyoweb.4.9.17
Tfbyoweb.4.9.17Tfbyoweb.4.9.17
Tfbyoweb.4.9.17
 
Meetup django common_problems(1)
Meetup django common_problems(1)Meetup django common_problems(1)
Meetup django common_problems(1)
 
Beyond CSS Architecture
Beyond CSS ArchitectureBeyond CSS Architecture
Beyond CSS Architecture
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
 
Handout6 html frames
Handout6 html framesHandout6 html frames
Handout6 html frames
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
WordPress theme translation
WordPress theme translationWordPress theme translation
WordPress theme translation
 
Handout3 links
Handout3 linksHandout3 links
Handout3 links
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the Good
 
Stylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStartStylesheets for Online Help - Scott DeLoach, ClickStart
Stylesheets for Online Help - Scott DeLoach, ClickStart
 
CSS Layout Tutorial
CSS Layout TutorialCSS Layout Tutorial
CSS Layout Tutorial
 

Andere mochten auch

Andere mochten auch (6)

Ruby Crash Course
Ruby Crash CourseRuby Crash Course
Ruby Crash Course
 
Monk
MonkMonk
Monk
 
App Lego
App LegoApp Lego
App Lego
 
Firefox kiterjesztés fejlesztés
Firefox kiterjesztés fejlesztésFirefox kiterjesztés fejlesztés
Firefox kiterjesztés fejlesztés
 
GovLoop Online Innovator's Summit 9/2012
GovLoop Online Innovator's Summit 9/2012GovLoop Online Innovator's Summit 9/2012
GovLoop Online Innovator's Summit 9/2012
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Ähnlich wie Haml, Sass & Compass

Front End on Rails
Front End on RailsFront End on Rails
Front End on RailsJustin Halsall
 
Ajax On S2 Odp
Ajax On S2 OdpAjax On S2 Odp
Ajax On S2 Odpghessler
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!Greg Bell
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglKilian Valkhof
 
LAMP_TRAINING_SESSION_3
LAMP_TRAINING_SESSION_3LAMP_TRAINING_SESSION_3
LAMP_TRAINING_SESSION_3umapst
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7phuphax
 
Jade & Javascript templating
Jade & Javascript templatingJade & Javascript templating
Jade & Javascript templatingwearefractal
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from AustinLisa Adkins
 
Ajax ons2
Ajax ons2Ajax ons2
Ajax ons2Chad Davis
 
We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0wangjiaz
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Tatsuhiko Miyagawa
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching ResurrectedBen Scofield
 
Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentationrailsconf
 
5.2 nesting and floating elements
5.2 nesting and floating elements5.2 nesting and floating elements
5.2 nesting and floating elementsBulldogs83
 
JWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAXJWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAXHilary Mason
 

Ähnlich wie Haml, Sass & Compass (20)

Front End on Rails
Front End on RailsFront End on Rails
Front End on Rails
 
Ajax On S2 Odp
Ajax On S2 OdpAjax On S2 Odp
Ajax On S2 Odp
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Rails e suas Gems
Rails e suas GemsRails e suas Gems
Rails e suas Gems
 
User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
 
LAMP_TRAINING_SESSION_3
LAMP_TRAINING_SESSION_3LAMP_TRAINING_SESSION_3
LAMP_TRAINING_SESSION_3
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
 
Jade & Javascript templating
Jade & Javascript templatingJade & Javascript templating
Jade & Javascript templating
 
What I brought back from Austin
What I brought back from AustinWhat I brought back from Austin
What I brought back from Austin
 
Ajax ons2
Ajax ons2Ajax ons2
Ajax ons2
 
We9 Struts 2.0
We9 Struts 2.0We9 Struts 2.0
We9 Struts 2.0
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentation
 
5.2 nesting and floating elements
5.2 nesting and floating elements5.2 nesting and floating elements
5.2 nesting and floating elements
 
Lecture1 B Frames&Forms
Lecture1 B  Frames&FormsLecture1 B  Frames&Forms
Lecture1 B Frames&Forms
 
JWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAXJWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAX
 

KĂŒrzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂșjo
 

KĂŒrzlich hochgeladen (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Haml, Sass & Compass

  • 1. Haml, Sass, Compass BĂĄcsi LĂĄszlĂł bacsi.laszlo@virgo.hu
  • 2. Haml ‱ SablonozĂł motor ‱ HTML-nĂ©l egyszerƱbb Ă©s ĂĄtlĂĄthatĂłbb ‱ Nincs redundancia (DRY) ‱ Szemantikus kĂłd, szĂ©p kimenet
  • 3. Sass ‱ Haml szerƱ szintaxis StyleSheet-ekhez ‱ EgymĂĄsba ĂĄgyazott kivĂĄlasztĂłk ‱ Nincs redundancia (DRY) ‱ Konstansok Ă©s egyszerƱ mƱveletek ‱ ÚjrahasznĂĄlatĂł CSS mixinek
  • 4. ‱ A leĂ­rĂł kĂłd szĂ©p kellene legyen ‱ A leĂ­rĂł kĂłd nem kellene ismĂ©telje magĂĄt ‱ A leĂ­rĂł kĂłd jĂłl indentĂĄlt kellene legyen ‱ A struktĂșra tisztĂĄn lĂĄthatĂł kellene legyen
  • 6. Alapok Haml HTML #content <div id='content'> .left.column <div class='left column'> %h2 Welcome to our site! <h2>Welcome to our site!</h2> %p= print_information <p> .right.column= render :partial => quot;sidebarquot; <%= print_information %> </p> </div> <div class=quot;right columnquot;> <%= render :partial => quot;sidebarquot; %> </div> </div>
  • 7. Alapok Haml HTML %tagname{:attr => 'value'} content <tagname attr=quot;valuequot;>content</tagname> %tagname#id.class content <tagname id=quot;idquot; class=quot;classquot;>content</ tagname> %tagname <tagname> %innerTag <innerTag/> and some content and some content </tagname> #company Virgo <div id=quot;companyquot;>Virgo</div> .employee BĂĄcsi LĂĄszlĂł <div class=quot;employeequot;>BĂĄcsi LĂĄszlĂł</div>
  • 8. -, = – Ruby kĂłd beĂĄgyazĂĄs Rubys Haml kĂłd GenerĂĄlt HTML %dl <dl> - now = DateTime.now <dt>DĂĄtum Ă©s idƑ:</dt> %dt DĂĄtum Ă©s idƑ: <dd> %dd Boldog Ășj Ă©vet! - if now > DateTime.parse('2008-12-31') </dd> Boldog Ășj Ă©vet! </dl> - else = now.to_s <dl> <dt>DĂĄtum Ă©s idƑ:</dt> <dd> 2008-12-30T12:31:45+01:00 </dd> </dl> - @gems = %w{rails haml compass} <ul id='gems'> %ul#gems <li class='gem'>rails</li> - @gems.each do |gem| <li class='gem'>haml</li> %li.gem= gem <li class='gem'>compass</li> </ul>
  • 9. {} – AttribĂștumok Haml HTML %bar/ <bar/> %script{:type => 'text/' + 'javascript', | <script src='/js/locale.hu.js' type='text/ :src => quot;/js/locale.#{@lang}.jsquot;} | javascript'></script> # ruby helperek def defaults {:type => 'checkbox', :value => '1'} end def override {:type => 'radio'} end <input type=quot;radioquot; value=quot;1quot; %input{defaults, override, :selected => true} selected=quot;selectedquot;/>
  • 10. [] – id Ă©s class generĂĄlĂĄs Haml HTML - @user = User.find(42) <div id=quot;current_user_42quot; %div[@user, :current] class=quot;current_userquot;> %span[7] 7. <span id=quot;fixnum_7quot; class=quot;fixnumquot;>7.</span> KĂșl, mi? KĂșl, mi? </div>
  • 11. ==, &=, !=, -# – Ruby inputok Haml HTML - name = quot;<b>Haml</b>quot; = quot;Hello, #{name}!quot; Hello, <b>Haml</b>! == Hello, #{name}! Hello, <b>Haml</b>! &= quot;Hello, #{name}!quot; Hello, &lt;b&gt;Haml&lt;/b&gt;! != quot;Hello, #{name}!quot; Hello, <b>Haml</b>! -# Ez itt egy komment, ami nem kerĂŒl ki
  • 12. !!! – xml Ă©s doctype Haml HTML !!! XML <?xml version='1.0' encoding='utf-8' ?> !!! XML iso-8859-2 <?xml version='1.0' encoding='iso-8859-2' ?> !!! Strict <!DOCTYPE html PUBLIC quot;-//W3C//DTD XHTML 1.0 Strict//ENquot; quot;http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtdquot;>
  • 13. / – Kommentek Haml HTML - name = quot;Calvinquot; <div class='user'> .user <!-- Ez itt a neve --> / Ez itt a neve Calvin = name </div> / <!-- Ezt a kĂłdot most egyelƑre nem rakjuk ki, Ezt a kĂłdot most egyelƑre nem rakjuk ki, mert problĂ©mĂĄk lehetnek belƑle. mert problĂ©mĂĄk lehetnek belƑle. %script <script> evil(); evil(); </script> --> <!--[if IE]> /[if IE] <link href='/css/ie.css' rel='stylesheet' %link{:href => quot;/css/ie.cssquot;, | type='text/css' /> :rel => quot;stylesheetquot;, | <![endif]--> :type => quot;text/cssquot;} |
  • 14. :markdown – Filterek Haml HTML %div <div> :markdown <h1>Hello <em>World</em>!</h1> # Hello *World*! </div> %Content{:type => 'html'} <Content type='html'> :cdata <![CDATA[ <p>iWiW gadzsett</p> <p>iWiW gadzsett</p> ]]> </Content> # sajĂĄt filter module Haml::Filters::Upcaser include Haml::Filters::Base def render(text) text.upcase end end %h1 <h1> :upcaser FIGYELEM, FIGYELEM! figyelem, figyelem! </h1>
  • 15. Sass
  • 16. Alapok Sass CSS #box #box { margin: 10px margin: 10px; color: #ff0 color: #ff0; } #box #box { :margin 10px margin: 10px; :color #ff0 color: #ff0; } #box #box { :margin 10px margin: 10px; :color #ff0 color: #ff0; } h1 #box h1 { :font-size 0.8em font-size: 0.8em; } a #box h1 a { :text-decoration none text-decoration: none; }
  • 17. Konstansok Sass CSS !highlight = #ccb !normal_text = 12px body body { :font-size = !normal_text font-size: 12px; } em em { :background-color = !highlight background-color: #ccccbb; } em.important em.important { :background-color = !highlight + #333 background-color: #ffffee; :font-size = 1.5 * !normal_text font-size: 18px; }
  • 18. Kommentek Sass CSS /* FejlĂ©c /* FejlĂ©c */ #header #header { :font-size 1em font-size: 1em; } // Ez itt meg bele se kerĂŒl a generĂĄlt css-be /* /* * Ez egy többsoros Ez egy többsoros * quot;hangosquot; komment */ quot;hangosquot; komment #footer { #footer font-size: 0.8em; } :font-size 0.8em // Ez pedig szintĂ©n több soros, de nem kerĂŒl be a css kĂłdba
  • 19. Bonyolultabb kombinĂĄciĂłk Sass CSS #main #main { :width 600px width: 600px; } p, div #main p, #main div { :font-size 1.5em font-size: 1.5em; } a #main p a, #main div a { :font-weight bold font-weight: bold; } img #main p a img, #main div a img { :border 0 border: 0; }
  • 20. SzĂŒlƑ vĂĄlasztĂł Sass CSS a a{ :color #00f color: #00f; } img a img { :border 0 border: 0; } &.disabled a.disabled { :color #444 color: #444; } &:link, &:active, &:visited a:link, a:active, a:visited { :text-decoration none text-decoration: none; } &:hover a:hover { :color #0ff color: #0ff; } img a:hover img { :border 2px solid #0ff border: 2px solid #0ff; } body.admin & body.admin a:hover img { :border-color #f00 border-color: #f00; }
  • 21. AttribĂștum namespace Sass CSS em em { :font font-size: 14px; :size 14px font-style: italic; :style italic font-family: Verdana, sans-serif; } :family Verdana, sans-serif
  • 22. ÚjrafelhasznĂĄlhatĂł kĂłdok Sass CSS =clearfix ul.images { display: inline-block display: inline-block; } &:after ul.images:after { content: quot;.quot; content: quot;.quot;; display: block display: block; height: 0 height: 0; clear: both clear: both; visibility: hidden visibility: hidden; } * html & * html ul.images { height: 1px height: 1px; } ul.images +clearfix p strong { =larger-text font-size: 1.2em; } :font-size 1.2em p strong em { p strong font-size: 1.2em; } +larger-text p strong em .important { em font-size: 1.2em; } +larger-text .important +larger-text
  • 23. ParamĂ©terek Ă©s kombinĂĄlĂĄs Sass CSS =hanging-indent(!indentation) p{ text-indent = -!indentation text-indent: -12px; padding-left = !indentation padding-left: 12px; } p +hanging-indent(12px) =float-container #items { +clearfix display: inline-block; } div #items:after { float: left content: quot;.quot;; .clear display: block; clear: both height: 0; clear: both; #items visibility: hidden; } +float-container * html #items { height: 1px; } #items div { float: left; } #items .clear { clear: both; }
  • 24. @import Sass CSS // classes.sass .highlight { .highlight color: #ffe; } :color #ffe @import url(zen.css); @import classes.sass @font-face { font-family: quot;Bitstream Vera Sansquot;; @import zen.css src: url(http://foo.bar/bvs); } // egyĂ©b kukacokat is bĂ©kĂ©nhagyja @font-face :font-family quot;Bitstream Vera Sansquot; :src url(http://foo.bar/bvs)
  • 26. Mi az a Compass? ‱ Egy Sass-re Ă©pĂŒlƑ framework ‱ Több ismert CSS framework-öt tĂĄmogat Sass mixinek segĂ­tsĂ©gĂ©vel (Blueprint, YUI, 960.gs) ‱ Sok hasznos CSS mintĂĄt ad (reset, clearïŹx, no-bullets, horizontal-list, inline-list, inline-block, tag-cloud, alternating-rows-and-columns, stb.)
  • 27. screen.sass (pĂ©lda) @import blueprint/screen.sass @import blueprint/modules/grid.sass @import blueprint/modules/colors.sass @import compass/reset.sass @import compass/utilities.sass body.blueprint +blueprint-typography .container +container #header +column(24) h1 :float left #site-actions :float right +horizontal-list +no-bullets #main-content +column(18) +colborder #sidebar +column(5,true) #footer +column(24)
  • 29. Akkor ERB szemĂ©t? ‱ A kĂŒlönbözƑ template-ek megĂ©lnek egymĂĄs mellett ‱ show.html.erb, show.html.haml, feed.xml.builder, feed.xml.haml ‱ GenerĂĄlt ERB kĂłdok maradhatnak, amĂ­g ĂĄt nem kell Ă­rni ‱ AkĂĄr kombinĂĄlhatĂłak is
  • 30. És a CSS ‱ Sass nagyon hasonlĂ­t CSS-hez ‱ Csak kiszeded a {} Ă©s ; karaktereket Ă©s valid Sass ‱ html2haml, css2sass
  • 31. KonïŹgurĂĄlhatĂłsĂĄg ‱ :escape_html, :supress_eval, :autoclose, :preserve, stb. ‱ :style, :attribute_syntax
  • 32. TelepĂ­tĂ©s $ git clone git://github.com/nex3/haml.git $ cd haml && rake install; cd .. $ git clone git://github.com/chriseppstein/compass.git $ cd compass && rake install; cd .. $ cd /my/cool/rails/project $ haml --rails . $ compass --rails -f blueprint Compass recommends that you keep your stylesheets in app/stylesheets/ instead of the Sass default location of public/stylesheets/sass/. Is this OK? (Y/n) y Compass recommends that you keep your compiled css in public/stylesheets/ compiled/ instead the Sass default of public/stylesheets/. However, if you're exclusively using Sass, then public/stylesheets/ is recommended. Emit compiled stylesheets to public/stylesheets/compiled? (Y/n) n directory app/stylesheets/ create app/stylesheets/screen.sass create app/stylesheets/print.sass create app/stylesheets/ie.sass create config/initializers/compass.rb create app/views/layouts/application.html.haml
  • 33. TovĂĄbbi infĂłk ‱ http://haml.hamptoncatlin.com/ ‱ http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml.html ‱ http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html ‱ http://wiki.github.com/chriseppstein/compass/ ‱ http://acts-as-architect.blogspot.com/2008/11/compass- primer.html ‱ http://www.blueprintcss.org/