← Extractions

Extracting logic from templates with Hanami Views (wroclove.rb 2024)

Sebastian Wilgosz presents Hanami 2.1's view layer at wroclove.rb 2024 as an inspiration for the broader Ruby/Rails audience. Using a registration-form example, he walks through how Hanami's views, parts (decorators), scopes, and helpers separate presentation logic from templates into small, testable Ruby objects, and argues the Rails community should borrow from non-Rails approaches.

Model
claude-opus-4-7
Ingestion
897114aa
Input tokens
362,264
fresh
275,351
cached
81,345
cache write
5,568
Output tokens
8,665
Duration
141.9s
Roundtrips
9
Tool calls
20
Cost
$0.00
Nodes/edges extracted
11 / 30
Read set (nodes/edges)
125 / 2

Nodes (11)

update Extracting logic from templates with Hanami Views talk
attrs {"type" => "talk"} {"date" => "2024-03-22", "type" => "talk"}
description Talk at wroclove.rb 2024. Single-speaker talk at wroclove.rb 2024 by Sebastian Wilgosz, aimed at the ~99% of the audience who don't use Hanami ...
short_description Talk at wroclove.rb 2024. Sebastian Wilgosz's wroclove.rb 2024 talk on Hanami's view layer as inspiration for Rails.
update Sebastian Wilgosz person
description Conference speaker. Ruby developer with a ~9-year career. Hanami advocate and blogger — notes he is effectively the only person blogging ...
short_description Conference speaker. Ruby/Hanami developer, blogger, and wroclove.rb speaker.
update Hanami tool
description Ruby web framework. Does not ship its own real-time/cable solution; combined with LiteCable + AnyCable in an Internet... Ruby web framework and Rails alternative. Occupies roughly 5% of the Ruby web-framework market alongside Roda, Sinatr...
short_description Alternative Ruby web framework to Rails. Modular Ruby web framework positioned as a Rails alternative.
create Hanami View tool
kind (empty) tool
name (empty) Hanami View
slug (empty) hanami-view
attrs (empty) {"version" => "2.1", "category" => "library"}
description (empty) View-layer gem that became officially 'done' with the Hanami 2.1 release and is packaged as a standalone, framework-a...
short_description (empty) Framework-agnostic Ruby view gem extracted from Hanami 2.1.
create Hanami View Part concept
kind (empty) concept
name (empty) Hanami View Part
slug (empty) hanami-view-part
attrs (empty) {"category" => "pattern"}
description (empty) A part in Hanami View is a Ruby class used to decorate values that the view exposes to a template. In Wilgosz's regis...
short_description (empty) Decorator Ruby class in Hanami View wrapping exposed values with presentation methods.
create Hanami View Scope concept
kind (empty) concept
name (empty) Hanami View Scope
slug (empty) hanami-view-scope
attrs (empty) {"category" => "pattern"}
description (empty) A scope in Hanami View is a Ruby class whose instance methods compute the locals required by a partial, so templates ...
short_description (empty) Hanami View Ruby object that computes the locals needed by a partial.
create Roda tool
kind (empty) tool
name (empty) Roda
slug (empty) roda
attrs (empty) {"category" => "framework"}
description (empty) Lightweight Ruby web framework cited by Wilgosz as the archetype of a plugin-based web stack: you install each piece ...
short_description (empty) Lightweight Ruby web framework built on a routing tree and plugin system.
create Rails Is All Or Nothing concept
kind (empty) concept
name (empty) Rails Is All Or Nothing
slug (empty) rails-is-all-or-nothing
attrs (empty) {"category" => "architecture"}
description (empty) Wilgosz's framing of a recurring Rails pain point: it took years for Rails to let developers build API-only apps with...
short_description (empty) Critique that Rails makes replacing or disabling core components very hard.
create Borrow From Non-Rails View Approaches takeaway
kind (empty) takeaway
name (empty) Borrow From Non-Rails View Approaches
slug (empty) borrow-from-non-rails-view-approaches
attrs (empty) {"type" => "recommendation"}
description (empty) Takeaway from Wilgosz's wroclove.rb 2024 talk: templating is genuinely hard, and different Ruby projects attack view-...
short_description (empty) Don't be afraid to use non-Rails view patterns (Hanami View, ViewComponent, Phlex) in Rails apps.
create Use Parts To Guarantee Non-Nil Collections takeaway
kind (empty) takeaway
name (empty) Use Parts To Guarantee Non-Nil Collections
slug (empty) use-parts-to-guarantee-non-nil-collections
attrs (empty) {"type" => "insight"}
description (empty) Practical insight from the Hanami View refactor: by decorating the form hash with a RegistrationFormPart that defines...
short_description (empty) Wrap exposed values in Hanami View parts so templates get safe defaults like empty arrays instead of nil.
create Extract Scopes When Partials Get Too Many Locals takeaway
kind (empty) takeaway
name (empty) Extract Scopes When Partials Get Too Many Locals
slug (empty) extract-scopes-when-partials-get-too-many-locals
attrs (empty) {"type" => "recommendation"}
description (empty) Guidance from Wilgosz's walkthrough: as you unify a partial for multiple use cases (e.g. a single text_field partial ...
short_description (empty) Use scopes to keep partials reusable without threading a long list of locals through templates.

Edges (30)

update Sebastian WilgoszauthoredExtracting logic from templates with Hanami Views
context (empty) Single speaker at wroclove.rb 2024
update Extracting logic from templates with Hanami Viewspresented_atwroclove.rb 2024
context (empty) Talk given at the 2024-03-22 wroclove.rb conference
create Sebastian Wilgoszattendedwroclove.rb 2024
context (empty) Speaker at the conference
relation (empty) attended
source_node_id (empty) 066df10f-fe3a-41dc-82c3-87676ddfcf70
target_node_id (empty) 748e0524-a102-41d4-97dc-575881583d91
create Extracting logic from templates with Hanami ViewsaboutHanami
context (empty) Whole talk frames Hanami as a modular Rails alternative
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 9e549b38-6071-4b4d-88ea-ca5c3d86afa7
create Extracting logic from templates with Hanami ViewsaboutHanami View
context (empty) Main subject: the Hanami View gem (2.1) and its layers
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
create Extracting logic from templates with Hanami ViewsaboutHanami View Part
context (empty) Demonstrates parts as decorators for exposed form values
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 918c7b77-4b7c-420b-b1c4-1b75ebdbf03d
create Extracting logic from templates with Hanami ViewsaboutHanami View Scope
context (empty) Demonstrates scopes computing locals for a unified text_field partial
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 6f9fa0b1-d3eb-4a98-bef6-83b801a40f68
create Extracting logic from templates with Hanami ViewsaboutRuby on Rails
context (empty) Contrasts Hanami with Rails' MVC, helpers, and all-or-nothing structure
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 7aac705a-0987-49f2-b665-9d4e08a6acee
create Extracting logic from templates with Hanami ViewsaboutN+1 Queries
context (empty) Cited as an example of issues nearly unique to the Rails ecosystem
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) ee033151-443a-4285-aa68-fbc2e9755d06
create Extracting logic from templates with Hanami ViewsaboutRails Is All Or Nothing
context (empty) Talk critiques Rails' difficulty to disable or replace core components
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 34685b69-3320-48af-83c1-19274adc1686
create Extracting logic from templates with Hanami ViewsaboutService Object
context (empty) Listed among community-invented Rails abstractions not backed by Rails philosophy
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) b8d19b36-ebfb-4be1-bba5-790358c566d1
create Extracting logic from templates with Hanami ViewsaboutViewComponent
context (empty) Mentioned as another project attacking the view-logic extraction problem
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) aaa7fac1-54d6-4dde-8805-bbc7219cd58a
create Extracting logic from templates with Hanami ViewsaboutPhlex
context (empty) Mentioned (as 'Flex') as another innovative view-logic solution
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 6bb19a01-47fc-4521-83c9-874cd58c606a
create Extracting logic from templates with Hanami ViewsaboutRoda
context (empty) Cited as the archetype of plugin-based modular Ruby frameworks
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) 297b342f-a3ad-4553-8598-60c3bb20324f
create Extracting logic from templates with Hanami ViewsaboutAppSignal
context (empty) Referenced as having dedicated UI for monitoring N+1 queries
relation (empty) about
source_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
target_node_id (empty) aced24a8-299a-442d-97eb-94d0a62763e7
create Hanamirelated_toRoda
context (empty) Hanami's modular architecture compared to Roda's plugin system
relation (empty) related_to
source_node_id (empty) 9e549b38-6071-4b4d-88ea-ca5c3d86afa7
target_node_id (empty) 297b342f-a3ad-4553-8598-60c3bb20324f
create Hanamirelated_toHanami View
context (empty) Hanami View is the view layer extracted from the Hanami framework in 2.1
relation (empty) related_to
source_node_id (empty) 9e549b38-6071-4b4d-88ea-ca5c3d86afa7
target_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
create Hanami Viewrelated_toHanami View Part
context (empty) Parts are one of Hanami View's building blocks
relation (empty) related_to
source_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
target_node_id (empty) 918c7b77-4b7c-420b-b1c4-1b75ebdbf03d
create Hanami Viewrelated_toHanami View Scope
context (empty) Scopes are one of Hanami View's building blocks
relation (empty) related_to
source_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
target_node_id (empty) 6f9fa0b1-d3eb-4a98-bef6-83b801a40f68
create Borrow From Non-Rails View Approachesfrom_talkExtracting logic from templates with Hanami Views
context (empty) Closing recommendation of the talk
relation (empty) from_talk
source_node_id (empty) 246d986c-47c4-4ad8-85f5-0ff30c0bf7ce
target_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
create Borrow From Non-Rails View ApproachesaboutHanami View
context (empty) Recommends Hanami View as a source of inspiration
relation (empty) about
source_node_id (empty) 246d986c-47c4-4ad8-85f5-0ff30c0bf7ce
target_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
create Borrow From Non-Rails View ApproachesaboutViewComponent
context (empty) Cited as an alternative approach to view-logic extraction
relation (empty) about
source_node_id (empty) 246d986c-47c4-4ad8-85f5-0ff30c0bf7ce
target_node_id (empty) aaa7fac1-54d6-4dde-8805-bbc7219cd58a
create Borrow From Non-Rails View ApproachesaboutPhlex
context (empty) Cited as an alternative approach to view-logic extraction
relation (empty) about
source_node_id (empty) 246d986c-47c4-4ad8-85f5-0ff30c0bf7ce
target_node_id (empty) 6bb19a01-47fc-4521-83c9-874cd58c606a
create Use Parts To Guarantee Non-Nil Collectionsfrom_talkExtracting logic from templates with Hanami Views
context (empty) Derived from the parts/errors method example
relation (empty) from_talk
source_node_id (empty) a6d7b3e9-caf4-405b-be21-853e58f9c299
target_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
create Use Parts To Guarantee Non-Nil CollectionsaboutHanami View Part
context (empty) Practical pattern using parts
relation (empty) about
source_node_id (empty) a6d7b3e9-caf4-405b-be21-853e58f9c299
target_node_id (empty) 918c7b77-4b7c-420b-b1c4-1b75ebdbf03d
create Extract Scopes When Partials Get Too Many Localsfrom_talkExtracting logic from templates with Hanami Views
context (empty) Derived from the unified text_field partial refactor
relation (empty) from_talk
source_node_id (empty) 88993114-01c2-4c8e-94d7-a3bb40088ae0
target_node_id (empty) 6397ebf7-f490-4fa3-8391-1d1d4072df2e
create Extract Scopes When Partials Get Too Many LocalsaboutHanami View Scope
context (empty) Recommendation centers on using scopes
relation (empty) about
source_node_id (empty) 88993114-01c2-4c8e-94d7-a3bb40088ae0
target_node_id (empty) 6f9fa0b1-d3eb-4a98-bef6-83b801a40f68
create Sebastian Wilgoszhas_skillHanami
attrs (empty) {"level" => "expert"}
context (empty) Long-time Hanami user who blogs about the framework
relation (empty) has_skill
source_node_id (empty) 066df10f-fe3a-41dc-82c3-87676ddfcf70
target_node_id (empty) 9e549b38-6071-4b4d-88ea-ca5c3d86afa7
create Sebastian WilgoszrecommendsHanami View
context (empty) Presents Hanami View as inspiration for Rails developers
relation (empty) recommends
source_node_id (empty) 066df10f-fe3a-41dc-82c3-87676ddfcf70
target_node_id (empty) 9ffa56e5-4e55-476d-97d0-482406b25385
create Sebastian Wilgoszhas_skillRuby on Rails
attrs (empty) {"level" => "expert"}
context (empty) Describes ~9-year career as a Ruby/Rails developer
relation (empty) has_skill
source_node_id (empty) 066df10f-fe3a-41dc-82c3-87676ddfcf70
target_node_id (empty) 7aac705a-0987-49f2-b665-9d4e08a6acee

Read set

125 nodes

event Advent of Code list_nodes_by_kind event Brighton Ruby list_nodes_by_kind event EmberConf list_nodes_by_kind tool Hanami search_nodes concept Cynefin Framework search_nodes project monolith framework search_nodes tool hanami-events search_nodes talk Extracting logic from templates with Hanami Views search_nodes+get_node_edges project Ruby UI search_nodes tool Rack search_nodes talk Towards the post framework future search_nodes tool Ruby on Rails search_nodes tool Jekyll search_nodes tool Speaker Deck search_nodes talk Offline Sandwich Focus Workflow search_nodes takeaway Name Things To Find Their Properties search_nodes question Including Unavailable Domain Experts search_nodes person Sebastian Wilgosz search_nodes+get_node_edges concept View-Biased Event Schemas search_nodes tool ViewComponent search_nodes concept Command Form search_nodes takeaway UI Data Is Never Truly Fresh search_nodes tool Lookbook search_nodes takeaway ViewComponent Checklist search_nodes concept Application Logic vs Business Logic search_nodes concept Sometimes Nothing Is Enough search_nodes concept Embrace The Evented Model search_nodes event 2NIT Nerds on Lakes Sailing Trip list_nodes_by_kind event Eventide Summit 2023 list_nodes_by_kind event Hacktoberfest list_nodes_by_kind event KanDDDinsky list_nodes_by_kind event Rails World list_nodes_by_kind event wroclove.rb 2018 list_nodes_by_kind event wroclove.rb 2019 list_nodes_by_kind event wroclove.rb 2022 list_nodes_by_kind event wroclove.rb 2023 list_nodes_by_kind event wroclove.rb 2024 list_nodes_by_kind event wroclove.rb 2025 list_nodes_by_kind event wroclove.rb 2026 list_nodes_by_kind question How do you test rendered Phlex components? search_nodes tool Phlex search_nodes concept ViewComponent Slots search_nodes takeaway Phlex is only faster than ERB at scale search_nodes talk Building Beautiful UIs with Ruby A Rails-Native Approach search_nodes talk Component Driven UI with ViewComponent search_nodes concept N+1 Queries search_nodes concept Database Indexes search_nodes question Is Active Record N+1 still a problem on SQLite? search_nodes concept Vector Database search_nodes question Aren't query optimizations a better first step than caching? search_nodes question Do wide models with many columns hurt performance? search_nodes takeaway Release DB connections around external HTTP calls search_nodes concept GraphQL performance regression tests search_nodes concept Isolated Reader/Writer Connection Pools search_nodes takeaway Read models must not depend on each other search_nodes tool AppSignal search_nodes tool Sentry search_nodes tool Honeycomb search_nodes tool New Relic search_nodes takeaway Narrow the Blocker by Comparing Environments search_nodes tool PagerDuty search_nodes tool Render search_nodes tool Datadog search_nodes tool pganalyze search_nodes project BBC Sport App search_nodes project Bridgetown search_nodes concept AI Agent search_nodes tool langchainrb search_nodes concept Retrieval Augmented Generation search_nodes project Ruby Romania search_nodes concept DNS geolocation routing search_nodes concept GraphQL max_depth search_nodes tool SXG Validator search_nodes tool RealtimeBoard search_nodes concept Service Object search_nodes takeaway Service Objects Are Not Domain Services search_nodes concept Stateless Service Object search_nodes talk The Curse of Service Object search_nodes tool Deface search_nodes question Wrapper Job vs Logic In Job search_nodes takeaway Prefer a simple top-to-bottom worker search_nodes takeaway ActiveSupport Notifications as cheap built-in instrumentation search_nodes takeaway Don't Use Interactors search_nodes concept Ruby Module Customization Mechanics search_nodes resource Rails Architect Master Class search_nodes concept Onion Architecture search_nodes question Is MVC enough for a successful enterprise app? search_nodes concept MVC Modularity Violations search_nodes concept Architecture Drivers search_nodes concept Fat Model Thin Controller search_nodes concept Hexagonal Architecture search_nodes question Do Rails adopters write handlers instead of controller actions? search_nodes concept Event-Driven Architecture search_nodes takeaway Give Unto Rails That Which Is Rails search_nodes concept Partial Rendering Overhead search_nodes concept Default scope for region preview search_nodes concept Builder Pattern for ViewComponents search_nodes concept Scope Concerns search_nodes concept Active Record search_nodes concept Active Record Custom Types search_nodes concept ActiveRecord Encryption search_nodes tool Active Storage search_nodes talk Better ActiveRecord IRB Output Gem Lightning Talk search_nodes tool activerecord-multi-tenant search_nodes tool ROM search_nodes takeaway Split Active Record into write and read objects search_nodes tool paper_trail search_nodes takeaway Rename app/models to app/data search_nodes tool Plezi search_nodes tool Express.js search_nodes tool Iodine search_nodes tool server-engine search_nodes takeaway Smoke Test ViewComponents via Lookbook Previews search_nodes tool cssbundling-rails search_nodes tool IronRuby search_nodes tool async search_nodes tool merb search_nodes tool Ruby search_nodes takeaway Read the Ruby standard library search_nodes question How do pure front-end developers react to Ruby views? search_nodes tool Cells search_nodes takeaway Avoid params-driven development search_nodes concept Rails RouteSet clear search_nodes concept Named Routes and I18n Everywhere search_nodes concept Rails Engine search_nodes

2 edges