← Graph

Extract Scopes When Partials Get Too Many Locals

takeaway 2 connections

Guidance from Wilgosz's walkthrough: as you unify a partial for multiple use cases (e.g. a single text_field partial for username/password/terms-of-service), the number of dynamic locals grows (control class names, `has_icons_right`, placeholder, input classes, icon partial). Rather than computing these in the template or passing them explicitly, define a Hanami View scope whose methods derive them from a minimal input (field name, errors, placeholder, label). Keeps templates tiny and the calculation testable.

type
recommendation
takeaway Extract Scopes When Partials Get Too Many Locals
about
Recommendation centers on using scopes
takeaway Extract Scopes When Partials Get Too Many Locals
from_talk
Derived from the unified text_field partial refactor

Provenance