Class: Tailwindcss::Formatter::ClassSorter
- Inherits:
-
Object
- Object
- Tailwindcss::Formatter::ClassSorter
- Defined in:
- lib/tailwindcss/formatter/class_sorter.rb
Overview
The Tailwindcss::Formatter::ClassSorter class is responsible for sorting Tailwind CSS classes in a consistent order according to best practices. This helps ensure that Tailwind CSS classes in HTML or other templates are ordered logically, improving readability and maintainability of the code.
The sorting is based on predefined patterns for class categories such as layout, typography, colors, etc.
Instance Method Summary collapse
-
#initialize(check_formatted: false, write: false) ⇒ ClassSorter
constructor
A new instance of ClassSorter.
- #process_file(file) ⇒ Object
Constructor Details
#initialize(check_formatted: false, write: false) ⇒ ClassSorter
Returns a new instance of ClassSorter.
15 16 17 18 |
# File 'lib/tailwindcss/formatter/class_sorter.rb', line 15 def initialize(check_formatted: false, write: false) @check_formatted = check_formatted @write = write end |
Instance Method Details
#process_file(file) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tailwindcss/formatter/class_sorter.rb', line 20 def process_file(file) original_content = File.read(file) formatted_content = format_content(original_content) # Check if the file was formatted if formatted_content == original_content # File was allready formatted correctly puts "\e[90m#{file}\e[0m" else puts file fail_format_check if @check_formatted File.write(file, formatted_content) if @write end end |