Maintainable Templates
summary
Templates stop being a mess when presentation logic moves into small, testable objects: use the masked credit card example to see a decorator hide formatting, adopt the decorator pattern or the draper gem for model-specific view behavior, extract UI-element logic into a story summary view object (presentation model) that renders itself, and replace repeated form markup with a custom form builder or gems like simple_form and tablecloth so changed HTML or labels updates once and actually fixes the maintenance pain.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 0:57Neglected templates in Rails
- 2:01Markup repetition with partials
- 3:25Logic dangers in templates
- 5:17Helpers for view logic
- 7:42Decorator pattern for views
- 11:32Draper gem
- 13:18Presentation models
- 18:31Clean templates with objects
- 20:15Custom form builders
- 21:23Internationalization tips
related talks
48mPresenters and Decorators: A Code Tour
28mDo Your Views Know Too Much?
34mCurly — Rethinking the View Layer
32mWhere did the OO go? Views Should be Objects Too!
40mBlow Up Your Views
29mExtracting logic from templates with Hanami Views
41mConcerns, Decorators, Presenters, Service Objects, Helpers, Help Me Decide!
38mRefactoring Fat Models with Patterns
