Created
March 26, 2011 14:07
-
-
Save denysonique/888302 to your computer and use it in GitHub Desktop.
Example given by Apeiros, how to use his css parser to edit CSS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
css = Browsr::CSS.new | |
css.append_external_stylesheet( | |
"#example-id { font-size: 12px; }", # the css definitions | |
:author_style_sheet, # origin of the definitions (relevant for specificity) | |
Browsr::CSS::Media::AllMedia, # media these rules apply for | |
"(demofile)", # file to report for definitions & errors | |
1 # line to report for definitions & errors | |
) | |
ruleset = css.first # normally you'd ask for all rulesets for a given medium | |
rule = ruleset.rules["#example-id"] | |
puts rule.to_css # prints the rule | |
rule['font-weight'] = "bold" | |
puts rule.to_css # prints the rule with the update applied |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment