Looking for a good practice to reuse partial templates / components?

Hello,

I am new to Elixir, I am looking for a good practice to reuse partial templates. For example a generic text_input already wrapped by a styled div, form label and error.

Of course with render function but I think there is a better way.

Perhaps with a view helper?
Or with components?

Also, this would be useful for me to make reusable component like Card, Article, Comment, Message, … (like in Jinja, Laravel’s Blade, React.js, Marko.js, Vue, etc)

Any advice, example, tuto is welcome :slight_smile:

1 Like

Function components.

I don’t know how much reuse I’d get out of wrapping an individual text input in a form though.

Ok thank you, I think I’ll go to move towards browser side form management with HTML custom elements.
Probably function components for reusable partial templates on the server side.

I would suggest trying out components. I’m a happy Surface user, but it seems quite a few of it’s features are coming to Phoenix soon.

2 Likes

Seems really convenient.