- Inheritance
- < BlankSlate < Object
Create a Cascading Style Sheet (CSS) using Ruby.
Example usage:
css = Builder::CSS.new
text_color = '#7F7F7F'
preferred_fonts = 'Helvetica, Arial, sans_serif'
css.comment! 'This is our stylesheet'
css.body {
background_color '#FAFAFA'
font_size 'small'
font_family preferred_fonts
color text_color
}
css.id!('navbar') {
width '500px'
}
css.class!('navitem') {
color 'red'
}
css.a :hover {
text_decoration 'underline'
}
css.div(:id => 'menu') {
background 'green'
}
css.div(:class => 'foo') {
background 'red'
}
This will yield the following stylesheet:
/* This is our stylesheet */
body {
background_color: #FAFAFA;
font_size: small;
font_family: Helvetica, Arial, sans_serif;
color: #7F7F7F;
}
#navbar {
width: 500px;
}
.navitem {
color: red;
}
a:hover {
text_decoration: underline;
}
div#menu {
background: green;
}
div.foo {
background: red;
}
Methods
Class
| Visibility | Signature |
|---|---|
| public | new (indent=2) |
Instance
| Visibility | Signature |
|---|---|
| public | + (part) |
| public | > (part) |
| public | >> (part) |
| public | class! (arg, &block) |
| public | comment! (comment_text) |
| public | group! (*args, &block) |
| public | id! (arg, &block) |
| public | method_missing (sym, *args, &block) |
| public | nil? () |
| public | store! (sym, &block) |
| public | target! () |
| public | | (part) |
Class Method Detail
new(indent=2)
Create a CSS builder.
| out: | Object receiving the markup.1 out must respond to <<. |
| indent: | Number of spaces used for indentation (0 implies no indentation and no line breaks). |
Instance Method Detail
+(part)
>(part)
>>(part)
class!(arg, &block)
comment!(comment_text)
Create a comment string in the output.
group!(*args, &block)
id!(arg, &block)
method_missing(sym, *args, &block)
nil?()
"Cargo culted" from Jim who also "cargo culted" it. See xmlbase.rb.
store!(sym, &block)
target!()
Return the target of the builder