~/talk

Extracting logic from templates with Hanami Views

Talkat wroc_love.rb 2024 · 2024-04-12..04-14· [ruby-on-rails]
slides:none on file

Hanami extracts template logic into Ruby objects so form rendering stays declarative: the Hanami View gem (2.1) is framework‑agnostic and provides Parts (decorators) and Scopes that compute locals, format errors, pick icons, and build control CSS classes. The demo shows a registration form refactored into a RegistrationPart that returns scope instances which render one reusable partial per input; it reduces template branching, is fully optional, and the extracted pieces are easily unit tested and reusable.

AI-written summary · about

  1. 0:00Introduction and motivation
  2. 2:14What is Hanami framework
  3. 4:26Ruby and Rails issues
  4. 8:42Hanami View introduction
  5. 9:48Logic in templates problem
  6. 13:02Form errors extraction
  7. 15:34Form input logic extraction
  8. 19:59Using Scopes for partials
  9. 22:12Decorating form inputs
  10. 25:08Conclusion and takeaways
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.