adamsrog / ember-cli-placeholdit

MIT License
1 stars 0 forks source link

Use helpers instead of a component #1

Open givanse opened 9 years ago

givanse commented 9 years ago

I think that a component is overkill for this type of thing, a helper should suffice.

If I do this:

{{placehold-it width=800 height=400 class="img-responsive"}}

The image is added like this:

<div id="ember360" class="ember-view img-responsive">
    <img src="http://placehold.it/800x400">
</div>

What I expected was:

<img class="img-responsive" src="http://placehold.it/800x400">

No div, no view/controller. Just an HTML tag, so a helper would be more appropriate. And of course, it should give us the ability to pass a CSS class.

Something like this: http://emberjs.com/guides/templates/writing-helpers/

adamsrog commented 9 years ago

@givanse thanks for the feedback! This was really just me experimenting with making an ember addon. I agree that this could be accomplished very easily with a helper. I will look into converting this to a helper to remove the overhead from Ember.Component.

In the mean time, I've updated the component to use an img tag and get rid of the unnecessary div (https://github.com/adamsrog/ember-cli-placeholdit/commit/5860b6ca9083e3d09313bbf77dcdafaac9447340).

{{placehold-it class="custom-class" width=200 height=100}}

will now output...

<img id="ember385" class="ember-view custom-class" src="http://placehold.it/200x100/aaa/555">
givanse commented 9 years ago

Thank you :+1: