blueprint-html2slim 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -5
- data/README.md +360 -35
- data/bin/slimtool +238 -0
- data/lib/blueprint/html2slim/link_extractor.rb +203 -0
- data/lib/blueprint/html2slim/slim_extractor.rb +286 -0
- data/lib/blueprint/html2slim/slim_fixer.rb +145 -0
- data/lib/blueprint/html2slim/slim_manipulator.rb +117 -0
- data/lib/blueprint/html2slim/slim_railsifier.rb +254 -0
- data/lib/blueprint/html2slim/slim_validator.rb +170 -0
- data/lib/blueprint/html2slim/version.rb +1 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27f4f166468ae3be90116e4ff94d8c9901eb72a033ef69b14822d6ed8ce8273
|
4
|
+
data.tar.gz: c7916bc01602176018608dc723e49816670d6e6688d890aedde2ec09b4901a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d019b9a611db510f8bd3ed39187c651c40dbd1dab414e7012cbb97d8e4cf06222034d45a1d06db44bf7709a3b822a12021af205fccf5b3482c325b9ca3377f89
|
7
|
+
data.tar.gz: 21da628071a957513c4faa67aedb8fe63ee76274efc3c9f08f6c0aeeae353b89017e7785b7fb144a8378718aaf297b9cebf1ba61ad9a623e79de411aad045dc1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,65 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [1.3.0] - 2025-01-16
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- **SlimExtractor enhancements**:
|
9
|
+
- Extract outline up to specified depth (`--outline N`) for high-level structure analysis
|
10
|
+
- Extract fragments by CSS selector (`--selector`) supporting #id, .class, element, and combinations
|
11
|
+
- **Comprehensive documentation**:
|
12
|
+
- Complete README with detailed examples for all commands
|
13
|
+
- All command options now have descriptive help text
|
14
|
+
- Added workflow examples and use cases
|
15
|
+
- Table of contents for easy navigation
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Improved command-line help system with detailed option descriptions
|
19
|
+
- Fixed extraction logic bug where keep/remove functionality wasn't working correctly
|
20
|
+
- Enhanced help output with categorized examples
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
- SlimExtractor now correctly handles keep/remove section logic
|
24
|
+
- Thor deprecation warnings resolved with `exit_on_failure?` method
|
25
|
+
- RuboCop style violations corrected
|
26
|
+
|
27
|
+
## [1.2.0] - 2025-01-16
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- New `slimtool` command-line utility for comprehensive Slim template manipulation
|
31
|
+
- **SlimFixer**: Automatically fixes common Slim syntax issues
|
32
|
+
- Fixes text starting with "/" that would be interpreted as comments (converts to pipe notation)
|
33
|
+
- Fixes multiline text blocks using proper pipe notation
|
34
|
+
- Supports backup and dry-run modes
|
35
|
+
- **SlimExtractor**: Extract or remove specific sections from Slim templates
|
36
|
+
- Remove unwanted sections (doctype, head, nav, footer, script, etc.)
|
37
|
+
- Keep only specified sections (main, article, or any element/class/id)
|
38
|
+
- Remove outer wrapper elements
|
39
|
+
- Extract outline up to specified depth (high-level structure only)
|
40
|
+
- Extract fragments by CSS selector (#id, .class, element, element.class#id)
|
41
|
+
- Custom output file support
|
42
|
+
- **SlimValidator**: Validate Slim syntax and check for potential issues
|
43
|
+
- Detects syntax errors (invalid indentation, unclosed brackets, empty Ruby markers)
|
44
|
+
- Strict mode: checks for tabs, inline styles, long lines
|
45
|
+
- Rails mode: checks for hardcoded URLs, static assets, missing CSRF tokens
|
46
|
+
- Comprehensive error and warning reporting
|
47
|
+
- **SlimRailsifier**: Convert static templates to Rails conventions
|
48
|
+
- Configurable link mappings via JSON/YAML files (no automatic guessing)
|
49
|
+
- Convert CDN assets to Rails asset pipeline helpers
|
50
|
+
- Add CSRF protection meta tags to forms
|
51
|
+
- Supports dry-run and backup modes
|
52
|
+
- **LinkExtractor**: Extract and analyze hardcoded links from templates
|
53
|
+
- Find all static HTML links, forms, assets, and images
|
54
|
+
- Categorize link types and suggest Rails helper conversions
|
55
|
+
- Multiple output formats (JSON, YAML, text)
|
56
|
+
- Batch processing of multiple files
|
57
|
+
- Comprehensive test suite for all new SlimTool features
|
58
|
+
|
59
|
+
### Changed
|
60
|
+
- Updated gem to include both `html2slim` and `slimtool` executables
|
61
|
+
- Rails link conversions now require explicit mappings (removed automatic fallback guessing)
|
62
|
+
- Improved command-line help with detailed examples and option descriptions
|
63
|
+
|
5
64
|
## [1.1.0] - 2025-01-16
|
6
65
|
|
7
66
|
### Added
|
@@ -23,10 +82,16 @@ All notable changes to this project will be documented in this file.
|
|
23
82
|
|
24
83
|
### Added
|
25
84
|
- Initial release of blueprint-html2slim
|
26
|
-
- HTML to Slim conversion
|
27
|
-
- ERB template support
|
28
|
-
- Smart file naming conventions
|
85
|
+
- HTML to Slim conversion with full HTML5 support
|
86
|
+
- ERB template support with proper Ruby code handling
|
87
|
+
- Smart file naming conventions (.html → .html.slim, .erb → .slim)
|
29
88
|
- Backup option for source files
|
30
89
|
- Recursive directory processing
|
31
|
-
- Dry-run mode
|
32
|
-
- Custom output path support
|
90
|
+
- Dry-run mode for previewing conversions
|
91
|
+
- Custom output path support
|
92
|
+
- Force overwrite option
|
93
|
+
- Delete source files after conversion
|
94
|
+
- Target directory support with structure preservation
|
95
|
+
- Custom indentation size support
|
96
|
+
- Comprehensive test suite with RSpec
|
97
|
+
- RuboCop integration for code quality
|
data/README.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
# Blueprint HTML2Slim
|
2
2
|
|
3
|
-
A Ruby gem providing
|
3
|
+
A comprehensive Ruby gem providing tools to convert HTML/ERB files to Slim format and manipulate Slim templates.
|
4
4
|
|
5
5
|
**Online Converter**: Try the web-based version at [https://railsblueprint.com/html2slim](https://railsblueprint.com/html2slim)
|
6
6
|
|
7
|
+
## Table of Contents
|
8
|
+
- [Requirements](#requirements)
|
9
|
+
- [Installation](#installation)
|
10
|
+
- [Tools Included](#tools-included)
|
11
|
+
- [HTML2Slim Converter](#html2slim-converter)
|
12
|
+
- [SlimTool - Template Manipulation](#slimtool---template-manipulation)
|
13
|
+
- [Features Overview](#features-overview)
|
14
|
+
- [Contributing](#contributing)
|
15
|
+
- [License](#license)
|
16
|
+
|
7
17
|
## Requirements
|
8
18
|
|
9
19
|
- Ruby 2.7 - 3.4 (compatible with latest Ruby versions)
|
@@ -28,7 +38,13 @@ Or install it yourself as:
|
|
28
38
|
gem install blueprint-html2slim
|
29
39
|
```
|
30
40
|
|
31
|
-
##
|
41
|
+
## Tools Included
|
42
|
+
|
43
|
+
This gem provides two command-line tools:
|
44
|
+
1. **html2slim** - Convert HTML/ERB files to Slim format
|
45
|
+
2. **slimtool** - Manipulate and fix existing Slim files
|
46
|
+
|
47
|
+
## HTML2Slim Converter
|
32
48
|
|
33
49
|
### Programmatic Usage (Ruby)
|
34
50
|
|
@@ -62,77 +78,386 @@ converter = Blueprint::Html2Slim::Converter.new(indent_size: 4)
|
|
62
78
|
|
63
79
|
### Command Line Usage
|
64
80
|
|
65
|
-
|
81
|
+
#### Basic Conversion
|
82
|
+
|
66
83
|
```bash
|
84
|
+
# Convert a single file
|
67
85
|
html2slim index.html
|
68
86
|
# Creates: index.html.slim
|
69
|
-
```
|
70
87
|
|
71
|
-
Convert with custom output
|
72
|
-
```bash
|
88
|
+
# Convert with custom output
|
73
89
|
html2slim -o custom.slim index.html
|
74
|
-
```
|
75
90
|
|
76
|
-
Convert multiple files
|
77
|
-
```bash
|
91
|
+
# Convert multiple files
|
78
92
|
html2slim file1.html file2.erb file3.html.erb
|
79
93
|
```
|
80
94
|
|
81
|
-
|
95
|
+
#### File Management Options
|
96
|
+
|
82
97
|
```bash
|
98
|
+
# Create backup of original files
|
83
99
|
html2slim -b index.html
|
84
100
|
# Creates: index.html.slim
|
85
101
|
# Renames: index.html -> index.html.bak
|
102
|
+
|
103
|
+
# Delete source files after conversion
|
104
|
+
html2slim -d old_templates/*.erb
|
105
|
+
# Converts and deletes the original .erb files
|
106
|
+
|
107
|
+
# Force overwrite without prompting
|
108
|
+
html2slim -f existing.html
|
86
109
|
```
|
87
110
|
|
88
|
-
|
111
|
+
#### Directory Processing
|
112
|
+
|
89
113
|
```bash
|
114
|
+
# Convert files in a directory recursively
|
90
115
|
html2slim -r ./views
|
91
|
-
```
|
92
116
|
|
93
|
-
Convert to target directory (preserves structure)
|
94
|
-
```bash
|
117
|
+
# Convert to target directory (preserves structure)
|
95
118
|
html2slim -t dist/ -r src/
|
96
119
|
# Converts src/views/index.html to dist/views/index.html.slim
|
97
120
|
```
|
98
121
|
|
99
|
-
|
100
|
-
```bash
|
101
|
-
html2slim -d old_templates/*.erb
|
102
|
-
# Converts and deletes the original .erb files
|
103
|
-
```
|
122
|
+
#### Preview and Testing
|
104
123
|
|
105
|
-
Dry run (preview what would be converted):
|
106
124
|
```bash
|
125
|
+
# Dry run (preview what would be converted)
|
107
126
|
html2slim -n file.html
|
127
|
+
|
128
|
+
# Custom indentation (default: 2 spaces)
|
129
|
+
html2slim -i 4 template.html
|
108
130
|
```
|
109
131
|
|
110
|
-
|
132
|
+
### Naming Conventions
|
111
133
|
|
112
134
|
- `file.html` → `file.html.slim`
|
113
135
|
- `file.html.erb` → `file.html.slim`
|
114
136
|
- `file.erb` → `file.slim`
|
115
137
|
|
116
|
-
|
138
|
+
### All HTML2Slim Options
|
117
139
|
|
118
|
-
- `-o, --output FILE` - Output file path (
|
140
|
+
- `-o, --output FILE` - Output file path (single file only)
|
119
141
|
- `-r, --recursive` - Process directories recursively
|
120
|
-
- `-n, --dry-run` -
|
142
|
+
- `-n, --dry-run` - Preview conversions without modifying files
|
121
143
|
- `-d, --delete` - Delete source files after successful conversion
|
122
|
-
- `-t, --target-dir DIR` - Target directory for converted files
|
144
|
+
- `-t, --target-dir DIR` - Target directory for converted files
|
123
145
|
- `-f, --force` - Overwrite existing files without prompting
|
124
|
-
- `-b, --backup` -
|
146
|
+
- `-b, --backup` - Create .bak backup of source files
|
125
147
|
- `-i, --indent SIZE` - Indentation size in spaces (default: 2)
|
126
148
|
- `-h, --help` - Show help message
|
127
149
|
- `-v, --version` - Show version
|
128
150
|
|
129
|
-
##
|
151
|
+
## SlimTool - Template Manipulation
|
152
|
+
|
153
|
+
The `slimtool` command provides advanced manipulation capabilities for Slim files.
|
154
|
+
|
155
|
+
### 1. Fix Common Syntax Issues
|
156
|
+
|
157
|
+
Automatically fix common Slim syntax problems:
|
158
|
+
|
159
|
+
```bash
|
160
|
+
# Fix text starting with forward slash (e.g., span /month)
|
161
|
+
slimtool fix pricing.slim
|
162
|
+
|
163
|
+
# Fix with backup
|
164
|
+
slimtool fix template.slim --backup
|
165
|
+
|
166
|
+
# Preview fixes without modifying
|
167
|
+
slimtool fix template.slim --dry-run
|
168
|
+
|
169
|
+
# Fix multiple files
|
170
|
+
slimtool fix views/*.slim
|
171
|
+
```
|
172
|
+
|
173
|
+
**Options:**
|
174
|
+
- `--fix-slashes` - Fix forward slashes in text (default: true)
|
175
|
+
- `--fix-multiline` - Fix multiline text blocks (default: true)
|
176
|
+
- `-b, --backup` - Create .bak backup before fixing
|
177
|
+
- `-n, --dry-run` - Preview changes without modifying files
|
178
|
+
|
179
|
+
**What it fixes:**
|
180
|
+
- Text starting with `/` that would be interpreted as comments
|
181
|
+
- Multiline text that should use pipe notation
|
182
|
+
- Common indentation issues
|
183
|
+
|
184
|
+
### 2. Extract Content Sections
|
185
|
+
|
186
|
+
Extract or remove specific sections from Slim templates:
|
187
|
+
|
188
|
+
```bash
|
189
|
+
# Remove unwanted sections
|
190
|
+
slimtool extract page.slim --remove head,nav,footer
|
191
|
+
|
192
|
+
# Keep only specific sections
|
193
|
+
slimtool extract page.slim --keep main,article
|
194
|
+
|
195
|
+
# Remove outer wrapper div
|
196
|
+
slimtool extract page.slim --remove-wrapper
|
197
|
+
|
198
|
+
# Extract outline (high-level structure only)
|
199
|
+
slimtool extract page.slim --outline 2
|
200
|
+
# Extracts only elements at depth 0 and 1
|
201
|
+
|
202
|
+
# Extract by CSS selector
|
203
|
+
slimtool extract page.slim --selector "#content"
|
204
|
+
slimtool extract page.slim --selector ".main-section"
|
205
|
+
slimtool extract page.slim --selector "article.featured"
|
206
|
+
|
207
|
+
# Custom output file
|
208
|
+
slimtool extract page.slim --output clean.slim
|
209
|
+
```
|
210
|
+
|
211
|
+
**Options:**
|
212
|
+
- `--keep SECTIONS` - Keep only specified sections
|
213
|
+
- `--remove SECTIONS` - Remove specified sections
|
214
|
+
- `-o, --output FILE` - Output file path
|
215
|
+
- `--remove-wrapper` - Remove single outer wrapper
|
216
|
+
- `--outline N` - Extract outline up to depth N
|
217
|
+
- `--selector CSS` - Extract fragment by CSS selector
|
218
|
+
|
219
|
+
**Supported CSS Selectors:**
|
220
|
+
- Element: `article`, `main`, `div`
|
221
|
+
- ID: `#content`, `#sidebar`
|
222
|
+
- Class: `.container`, `.main-section`
|
223
|
+
- Combined: `article.featured`, `div#main.container`
|
224
|
+
|
225
|
+
### 3. Validate Slim Syntax
|
226
|
+
|
227
|
+
Check for syntax errors and potential issues:
|
228
|
+
|
229
|
+
```bash
|
230
|
+
# Basic validation
|
231
|
+
slimtool validate template.slim
|
232
|
+
|
233
|
+
# Validate multiple files
|
234
|
+
slimtool validate views/**/*.slim
|
235
|
+
|
236
|
+
# Strict validation (style checks)
|
237
|
+
slimtool validate template.slim --strict
|
238
|
+
|
239
|
+
# Check Rails conventions
|
240
|
+
slimtool validate app.slim --check-rails
|
241
|
+
|
242
|
+
# Combined strict + Rails checks
|
243
|
+
slimtool validate *.slim --strict --check-rails
|
244
|
+
```
|
245
|
+
|
246
|
+
**Options:**
|
247
|
+
- `--strict` - Enable strict mode checks
|
248
|
+
- `--check-rails` - Check Rails best practices
|
249
|
+
|
250
|
+
**What it checks:**
|
251
|
+
|
252
|
+
**Basic validation:**
|
253
|
+
- Invalid indentation
|
254
|
+
- Unclosed brackets
|
255
|
+
- Empty Ruby code markers (`=` or `-` with no code)
|
256
|
+
- Text starting with `/` (would be interpreted as comment)
|
257
|
+
|
258
|
+
**Strict mode (`--strict`):**
|
259
|
+
- Tabs in indentation (enforces spaces only)
|
260
|
+
- Inline styles (suggests using CSS classes)
|
261
|
+
- Lines exceeding 120 characters
|
262
|
+
- Deprecated Slim syntax
|
263
|
+
|
264
|
+
**Rails checks (`--check-rails`):**
|
265
|
+
- Static asset links (suggests asset pipeline helpers)
|
266
|
+
- Hardcoded URLs (suggests Rails path helpers)
|
267
|
+
- Forms without Rails helpers
|
268
|
+
- Missing CSRF tokens in forms
|
269
|
+
- CDN assets that could use asset pipeline
|
270
|
+
|
271
|
+
### 4. Convert to Rails Conventions
|
272
|
+
|
273
|
+
Transform static Slim templates to use Rails helpers:
|
274
|
+
|
275
|
+
```bash
|
276
|
+
# Create a mappings file for URL conversions
|
277
|
+
cat > mappings.json << 'EOF'
|
278
|
+
{
|
279
|
+
"/": "root_path",
|
280
|
+
"/about": "about_path",
|
281
|
+
"/users": "users_path",
|
282
|
+
"/login": "new_session_path",
|
283
|
+
"/products": "products_path"
|
284
|
+
}
|
285
|
+
EOF
|
286
|
+
|
287
|
+
# Convert using mappings
|
288
|
+
slimtool railsify template.slim --mappings mappings.json
|
289
|
+
|
290
|
+
# Add CSRF protection to forms
|
291
|
+
slimtool railsify form.slim --add-csrf --mappings mappings.json
|
292
|
+
|
293
|
+
# Convert CDN assets to Rails asset pipeline
|
294
|
+
slimtool railsify layout.slim --use-assets
|
295
|
+
|
296
|
+
# Preview changes
|
297
|
+
slimtool railsify template.slim --mappings mappings.json --dry-run
|
298
|
+
|
299
|
+
# Process multiple files with backup
|
300
|
+
slimtool railsify views/*.slim --mappings mappings.json --backup
|
301
|
+
```
|
302
|
+
|
303
|
+
**Options:**
|
304
|
+
- `--mappings FILE` - JSON/YAML file with URL-to-helper mappings
|
305
|
+
- `--add-helpers` - Convert links to Rails helpers (default: true)
|
306
|
+
- `--use-assets` - Convert CDN assets to asset pipeline (default: true)
|
307
|
+
- `--add-csrf` - Add CSRF meta tags to head section
|
308
|
+
- `-b, --backup` - Create .bak backup before converting
|
309
|
+
- `-n, --dry-run` - Preview changes without modifying
|
310
|
+
|
311
|
+
**What it converts:**
|
312
|
+
- Static links to Rails path helpers (using your mappings)
|
313
|
+
- CDN stylesheets to `stylesheet_link_tag`
|
314
|
+
- CDN scripts to `javascript_include_tag`
|
315
|
+
- Static forms to include CSRF tokens
|
316
|
+
- Image paths to use `image_tag` helper
|
317
|
+
|
318
|
+
**Note:** Link conversions require explicit mappings - no automatic guessing.
|
319
|
+
|
320
|
+
### 5. Extract Hardcoded Links
|
321
|
+
|
322
|
+
Find and report all hardcoded links in templates:
|
323
|
+
|
324
|
+
```bash
|
325
|
+
# Display found links
|
326
|
+
slimtool extract-links template.slim
|
327
|
+
|
328
|
+
# Process multiple files
|
329
|
+
slimtool extract-links views/**/*.slim
|
330
|
+
|
331
|
+
# Save results to JSON
|
332
|
+
slimtool extract-links *.slim -o links.json
|
333
|
+
|
334
|
+
# Save in different formats
|
335
|
+
slimtool extract-links *.slim -o links.yaml --format yaml
|
336
|
+
slimtool extract-links *.slim -o links.txt --format text
|
337
|
+
|
338
|
+
# Find links in entire project
|
339
|
+
slimtool extract-links app/views/**/*.slim -o project_links.json
|
340
|
+
```
|
341
|
+
|
342
|
+
**Options:**
|
343
|
+
- `-o, --output FILE` - Save results to file
|
344
|
+
- `--format FORMAT` - Output format: json, yaml, or text (default: json)
|
345
|
+
|
346
|
+
**What it finds:**
|
347
|
+
- HTML anchor links (`a[href]`)
|
348
|
+
- Form action URLs
|
349
|
+
- Asset links (stylesheets, scripts)
|
350
|
+
- Image sources
|
351
|
+
- Any hardcoded paths that could use Rails helpers
|
352
|
+
|
353
|
+
**Output includes:**
|
354
|
+
- File location
|
355
|
+
- Line number
|
356
|
+
- Link type (anchor, form, asset, image)
|
357
|
+
- Original URL
|
358
|
+
- Suggested Rails helper (when applicable)
|
359
|
+
|
360
|
+
## Features Overview
|
361
|
+
|
362
|
+
### HTML2Slim Converter Features
|
363
|
+
- ✅ Full HTML5 support
|
364
|
+
- ✅ ERB template conversion
|
365
|
+
- ✅ Preserves all attributes and structure
|
366
|
+
- ✅ Smart ID/class shortcuts (`div#id.class`)
|
367
|
+
- ✅ Handles void elements correctly
|
368
|
+
- ✅ Preserves comments
|
369
|
+
- ✅ Unicode/UTF-8 support
|
370
|
+
- ✅ Multiline ERB code blocks
|
371
|
+
- ✅ Custom indentation
|
372
|
+
- ✅ Batch processing
|
373
|
+
- ✅ Directory recursion
|
374
|
+
|
375
|
+
### SlimTool Features
|
376
|
+
- ✅ **Syntax Fixing**
|
377
|
+
- Text starting with `/` (pipe notation)
|
378
|
+
- Multiline text blocks
|
379
|
+
- Common indentation issues
|
380
|
+
|
381
|
+
- ✅ **Content Extraction**
|
382
|
+
- Remove unwanted sections
|
383
|
+
- Keep specific sections
|
384
|
+
- Extract by CSS selector
|
385
|
+
- Extract outline by depth
|
386
|
+
- Remove wrapper elements
|
387
|
+
|
388
|
+
- ✅ **Validation**
|
389
|
+
- Syntax error detection
|
390
|
+
- Style checking (strict mode)
|
391
|
+
- Rails convention checking
|
392
|
+
- Comprehensive error reporting
|
393
|
+
|
394
|
+
- ✅ **Rails Integration**
|
395
|
+
- Convert links to helpers
|
396
|
+
- Asset pipeline integration
|
397
|
+
- CSRF token support
|
398
|
+
- Form helper suggestions
|
399
|
+
|
400
|
+
- ✅ **Link Analysis**
|
401
|
+
- Find all hardcoded URLs
|
402
|
+
- Categorize link types
|
403
|
+
- Suggest Rails helpers
|
404
|
+
- Multiple output formats
|
405
|
+
|
406
|
+
## Examples
|
407
|
+
|
408
|
+
### Complete Workflow Example
|
409
|
+
|
410
|
+
```bash
|
411
|
+
# 1. Convert HTML/ERB files to Slim
|
412
|
+
html2slim -r ./app/views_old -t ./app/views
|
413
|
+
|
414
|
+
# 2. Fix any syntax issues
|
415
|
+
slimtool fix app/views/**/*.slim --backup
|
416
|
+
|
417
|
+
# 3. Validate the converted files
|
418
|
+
slimtool validate app/views/**/*.slim --strict --check-rails
|
419
|
+
|
420
|
+
# 4. Extract hardcoded links for analysis
|
421
|
+
slimtool extract-links app/views/**/*.slim -o links.json
|
422
|
+
|
423
|
+
# 5. Create mappings based on found links
|
424
|
+
cat > url_mappings.json << 'EOF'
|
425
|
+
{
|
426
|
+
"/": "root_path",
|
427
|
+
"/dashboard": "dashboard_path",
|
428
|
+
"/users": "users_path",
|
429
|
+
"/login": "new_session_path"
|
430
|
+
}
|
431
|
+
EOF
|
432
|
+
|
433
|
+
# 6. Convert to Rails conventions
|
434
|
+
slimtool railsify app/views/**/*.slim --mappings url_mappings.json --add-csrf
|
435
|
+
|
436
|
+
# 7. Final validation
|
437
|
+
slimtool validate app/views/**/*.slim --check-rails
|
438
|
+
```
|
439
|
+
|
440
|
+
### Cleaning Up Templates
|
441
|
+
|
442
|
+
```bash
|
443
|
+
# Remove all navigation and footer from templates
|
444
|
+
slimtool extract views/*.slim --remove head,nav,footer,script
|
445
|
+
|
446
|
+
# Extract only the main content area
|
447
|
+
slimtool extract page.slim --selector "#main-content" -o clean.slim
|
448
|
+
|
449
|
+
# Get high-level structure for documentation
|
450
|
+
slimtool extract complex_page.slim --outline 2 -o structure.slim
|
451
|
+
```
|
452
|
+
|
453
|
+
## Contributing
|
454
|
+
|
455
|
+
1. Fork it
|
456
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
457
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
458
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
459
|
+
5. Create new Pull Request
|
460
|
+
|
461
|
+
## License
|
130
462
|
|
131
|
-
|
132
|
-
- Handles HTML attributes, IDs, and classes
|
133
|
-
- Preserves ERB tags (<%= %> and <% %>)
|
134
|
-
- Supports nested elements
|
135
|
-
- Handles void elements correctly
|
136
|
-
- Preserves comments
|
137
|
-
- Smart output file naming
|
138
|
-
- Optional source file backup
|
463
|
+
This gem is available as open source under the terms of the [MIT License](LICENSE).
|