Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Trailblazer Cells

Krzysztof
December 21, 2023

Trailblazer Cells

My old presentation, about trailblazer cells. It was intended as a Lighting Talk but always ended up being rather long due to me talking a lot. Probably not as meaty without the talking

Krzysztof

December 21, 2023
Tweet

More Decks by Krzysztof

Other Decks in Programming

Transcript

  1. Cells purpose Cells purpose • Removing business (and other) logic

    from views • Code readability goes up by a mile • Following OOP/SOLID/SRR/etc. • No more partials and helpers using global state of the app. • Cells want to segregate your UI into logical fragments • Rendering a template anywhere you want with eaze • Providing a logical and clean files structure and architecture
  2. Cell https://github.com/trailblazer/cells - View Object à la Controller - Does

    not have to be coupled with TB - It can render html anywhere (good to be used with emails as well as classic app views) - Not Rails dependent - Layout change with eaze (so controller doesn’t care about it since it is not his responsibility) - Cells will encourage and reward you for building the code for view in a way that provides the application with encapsulated UI fragments having access to only stuff they actually need to render a part of UI/view
  3. • Formats for views you can work on using cells:

    haml, hamlit, erb, slim • Cells can handle not only Active Records objects passed to it - they are fine handling basically anything you want. • Context withinh a cell rendered from controller contains its data by default and passes it further • You can also generate form inputs via Cells • You can redefine #show method and pass arguments Few other hints / informations