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

Extended renderEach with data objects support #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ggodet-bar
Copy link

Hello Aaron,

First of all, thanks for the great work on Sammy, this is really a cool project to work with. Back to my pull request: I extended renderEach so that it may handle data objects when interpolating with the template.

Cheers,

Guillaume

@quirkey
Copy link
Owner

quirkey commented Jan 16, 2011

I don't know if I completely understand the use case for this. Can you explain or give a better example of when you'd need two separate interpolation objects?

@ggodet-bar
Copy link
Author

Using two interpolation objects allows injecting data that is specific to the array element and generic data that applies to all rendered items.

Case study:
I'm working on yet another task management app. The task template requires a task object (obviously), but also generic data for filling dropdowns, such as the project id, available task statuses or available task priorities (which should be the same for all displayed tasks). Using the new renderEach method, I can thus call:
render_ctx.renderEach('templates/_task.html.erb', 'task', tasks_page, {project_id: project.id(), statuses: task_statuses, priorities: task_priorities}, task_callback) ;

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.

None yet

2 participants