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

Add image partial to handlebars #1764

Merged
merged 4 commits into from
Mar 15, 2017

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Mar 9, 2017

This adds a Handlebars partial for rendering images or their placeholder. As suggested by @tvdeyen in #1760

To be able to index the correctly sized image url, I needed to use the handlebars lookup helper, which allows looking up by a dynamic attribute, as well as introduce a new concat helper to get the correctly named key (ex. mini_url from "mini"). A little hacky, but it works well and isn't noticeable to anyone calling the partial.

At the same time I've moved the code to dig the image data out of the variant JSON into handlebars, which is a bit simpler and nicer.

With the previous change to the image placeholder this was displaying
incorrectly (the size was being calculated slightly differently). There
was no reason to float this outer div which had two inner floating divs.
When I first wrote this I didn't know how to index an array in
handlebars. Now I do!

This is better to have in handlebars because it's simpler and the JS
doesn't need to care that an image is being displayed.
@jhawthorn jhawthorn force-pushed the handlebars_image_partial branch from de595bc to 10508c1 Compare March 9, 2017 23:36
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This very nice

@tvdeyen
Copy link
Member

tvdeyen commented Mar 10, 2017

Who ever finds the verb can keep it 😅

Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great starting to see these small improvements add up

@jhawthorn jhawthorn merged commit 1412e87 into solidusio:master Mar 15, 2017
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.

4 participants