Skip to content
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

Create template helper for Scrapbook pages #4

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Create template helper for Scrapbook pages #4

merged 2 commits into from
Nov 30, 2023

Conversation

bfad
Copy link
Owner

@bfad bfad commented Nov 30, 2023

This creates a helper method named sb that can be used by the Scrapbook gem to provide helper methods to be used by the Scrapbook pages of the host application. The idea is that all the helper methods the Scrapbook gem creates will actually be methods on the object that sb returns. This enables us to minimize potential name conflicts with the host-app's helper methods. For example, in the future I want to be able to create example could and display its source. I may make a method named "display_view_source" that users could use in their Scrapbook pages by calling sb.display_view_source, and this wouldn't conflict with their own definition of "display_view_source" that they could potentially have in their host application.

Since I'm making this move, I'm also making scrapbook and pathname methods available to the object returned by sb. Right now every Scrapbook page is rendered with scrapbook and pathname as locals to those views, but in the future users will need to access them with sb.scrapbook and sb.pathname. Eventually, only the sb method could possibly conflict.

I want to create some potentially useful helper methods that users can
use inside their Scrapbook pages, but I don't want to potentially
conflict with any helper methods they have created. My solution is to
create a helper method named `sb` that returns an object that will have
the helper methods as its methods. For example, to get access to the
current Scrapbook object, a user can now call `sb.scrapbook`. (This
should eventually limit the potential conflicts to just `sb` — right now
both `pathname` and `scrapbook` could conflict because I pass them as
locals.
These locals will eventually be removed in favor of using the `sb`
helper method. Code needs to be updated to call `sb.scrapbook` and
`sb.pathname` instead. This should mean that the only possible conflict
that the Scrapbook gem could have with the host's helper methods will
eventually just be `sb`.
@bfad bfad merged commit 5a31d69 into main Nov 30, 2023
50 checks passed
@bfad bfad deleted the template-helper branch November 30, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant