http://alejandroelinformatico.com/slideshows/ca/nanoc-sass/
Alejandro el informático(@ainformatico). 2011.
Licencia Creative Commons by-nc-sa.
"sass is a meta-language on top of CSS that’s used to describe the style of a document cleanly and structurally, with more power than flat CSS allows."
html
estàtic de manera dinàmica.css
de manera àgil i dinàmica.$ nanoc cs test
create config.yaml
create Rakefile
create Rules
create content/index.html
create content/stylesheet.css
create layouts/default.html
Created a blank nanoc site at 'test'. Enjoy!
$ nanoc ci my_item
create content/my_item.html
An item has been created at /my_item/.
$ nanoc cl body
create layouts/body.html
A layout has been created at /body/.
$ nanoc co
Compiling site...
create [0.04s] output/my_item/index.html
create [0.00s] output/style.css
create [0.00s] output/index.html
Site compiled in 0.12s.
Compiling site...
update [0.01s] output/my_item/index.html
skip [0.00s] output/index.html
skip [0.00s] output/style.css
Site compiled in 0.02s.
---
title: A New Item
---
<h3><%= @item[:title] %></h3>
<p>
Item content
</p>
layouts/default.html
<%= yield %>
Rules
compile '/my_item/' do
layout 'body'
end
compile '*' do
filter :erb
layout 'default'
filter :relativize_paths, :type => :html
end
bluecloth, coderay, colorize_syntax, erb, erubis, haml, kramdown, less, markaby, maruku, rainpress, rdiscount, rdoc, redcloth, relativize_paths, rubypants, sass.
lib/default.rb
include Nanoc3::Helpers::Rendering
Render
<%= render "footer" %>
@item
:filename
:content_filename
:meta_filename
:extension
@item_rep
@item
@items
@layout
@layouts
@config
@site
#wrapper
width: 996px
margin: 0 auto
#main
width: 700px
padding: 10px
.news
li
padding: 10px
float: left
em, strong
color: #666
#wrapper {
width: 996px;
margin: 0 auto;
}
#main {
width: 700px;
padding: 10px;
}
#main .news li {
padding: 10px;
float: left;
}
#main .news li em, #main .news li strong {
color: #666;
}
$box_width: 300px
$main_width: $box_width * 3 + 96
$anchor_color: #999
$font_family: 'Helvetica', Arial, sans-serif
#header
color: $anchor_color
#main
width: $main_width
color: $anchor_color
font:
family: $font_family
@mixin shadow ($x: 1px, $y: 1px, $blur: $shadow_blur, $color: $shadow_color)
-moz-box-shadow: $x $y $blur $color
-webkit-box-shadow: $x $y $blur $color
box-shadow: $x $y $blur $color
.box
@include shadow(2px, 3px)
@import
@import "tables"
tables.sass
._tables.sass
.@import "tables.css"
tables.css
._tables.sass
vs tables.sass
En el moment de la compilació el fitxer _tables.sass
no tindrà fitxer de sortida mentre que tables.sass
sí, tables.css
.
css.sass
sass css.sass css.css
sass --watch css.sass:css.css
sass --watch css/[:output/css/]
nested
expanded
compressed
sass
vs scss
table.hl
margin: 2em 0
td.ln
text-align: right
li
font:
family: serif
weight: bold
size: 1.2em
table.hl {
margin: 2em 0;
td.ln {
text-align: right;
}
}
li {
font: {
family: serif;
weight: bold;
size: 1.2em;
}
}
Rules
.item_name.html
, per tan si volem canviar la extensió haurem de fer-ho manualment.content/css/
css.sass
_mixins.sass
_defines.sass
Rules
compile '/css/*' do
filter 'sass'
end
route '/css/*' do
item.identifier.chop + ".css"
end
$ nanoc co
Have fun!
http://esbudellat.net/slideshows/nanoc/ (Arnau Siches)
http://choangalvez.nom.es/presentaciones/sass/ (Choan Gálvez)