Skip to content

Instantly share code, notes, and snippets.

@LucoLe
Created October 5, 2018 16:21
Show Gist options
  • Save LucoLe/4024f472be6bf18b4d85f8ca604c15ed to your computer and use it in GitHub Desktop.
Save LucoLe/4024f472be6bf18b4d85f8ca604c15ed to your computer and use it in GitHub Desktop.
1. In the view template we put some formated comment that should link to the stylesheet that
will be used in this template.
2. Create sprockets preprocessor that converts the class names into predefined pattern:
- The preprocessor should be configurable so that for different environments it should be
possible to generate different hashed versions of the class names e.g. `[hash]`,
`[class_name]__[file_name]__[hash]`, the hash should also be configurable so the user can specify
how long it should be.
- Goes through the view template and finds the css classes.
- According to some configuration generates some sort of a hash for the given string.
- finds the css file/files specified in the comment, finds the all the occurances of the class that was
just changed in the template and changes the class name with the same hash.
- if a class is given only in the template but not present in the css files mentioned in the
comment then the class name is not changed.
3. Register the preprocessor for the appropriate file formats - current version of sprockets doesn't
support chainable file types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment