SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
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,
    clearfix, 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
Konfigurá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/

Más contenido relacionado

La actualidad más candente

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
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
Meetup django common_problems(1)
Meetup django common_problems(1)Meetup django common_problems(1)
Meetup django common_problems(1)Eric Satterwhite
 
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 3Nur Fadli Utomo
 
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
 

La actualidad más candente (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
 

Destacado

Destacado (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
 

Similar a Haml, Sass & Compass

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
 
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
 

Similar a 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
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
🐬 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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

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, clearfix, 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. Konfigurá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/