Module: Stylish::Formattable
- Included in:
- Declaration, Declarations, Image, PropertyBundle, Rule, Selectors, Tree::SelectorScope
- Defined in:
- lib/stylish/formattable.rb
Overview
The Formattable mixin gives an API for changing the output format of any of Stylish’s core classes, as long as the new output format matches the regex provided when the class was declared. This is because in order to generate valid CSS, strings must be joined in the correct way.
For example, a rule’s selectors must be comma-separated and its declarations must be wrapped in curly braces, while each declaration consists of a property name and a value separated by a colon and terminating with a semicolon.
In order to employ the Formattable mixin, it must be included into a class and the accept_format method must be called with the allowed format (as a regular expression) and the default format (a string).
class Stylesheet
include Formattable
accept_format(/\s*/m, "\n")
end
Defined Under Namespace
Modules: FormattableMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
24 25 26 |
# File 'lib/stylish/formattable.rb', line 24 def self.included(base) base.extend(FormattableMethods) end |