-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document working with Rails helpers — both built in and custom #10
Comments
Thanks for opening this issue. I agree the docs need some major clarification here and I’ve transferred it to the |
After working all week converting a bunch of views over to Phlex (love it btw!), I've found I was able to extract a decent amount of helpers into Phlex components. Compute-only helper methods used in multiple places can be placed in a file This or a similar suggestion about what to do with custom helper methods under app/helpers would at least get people headed in the right direction. |
Found this thread when searching for advice for what to do with presenter logic - similar question, I guess. I'm psyched to start using Phlex but i'm unsure where to put presenter logic - i'm guessing similar to @tubsandcans included module above. Example - I have an I instantiate the presenter it in a few places in the code where we need an image "with the works":
Since these would be separate Phlex components, I obviously want to reuse the logic. Advice welcome, even a short word in this thread, but some documentation of this pattern would be great too. |
@nimmolo depending on your requirements, either approach — having each component take a common presenter object, or having them share behaviour through inheritance from some common module or superclass — could make sense. You may also be able to have your carousel component just render the standalone image component for its own images and thumbnails. The library doesn’t have any opinions on this. |
Many Rails apps utilize the app/helpers feature for code reusability when rendering. I cannot figure out how to integrate the methods defined under app/helpers/ into Phlex's rendering pipeline, which seems very much like the kind of thing that would be pointed out under a Rails migration guide.
The docs make it clear how to create custom "helpers" for tags, which is nice but I absolutely need the logic in my helpers to become accessible inside Phlex classes/views. Also, the docs like to use the word "helpers" both for Rails built-in helpers and Plex's helpers, without a single mention of the existence of user-defined helpers under app/helpers, which is mildly confusing.
The text was updated successfully, but these errors were encountered: