1
0
Fork 0

Ingredients replacing lorem ipsum

This commit is contained in:
Ava Gaiety Wroten 2019-12-22 23:22:51 -06:00
parent a2e45705c1
commit a03953a0ab
3 changed files with 15 additions and 1 deletions

View file

@ -21,6 +21,7 @@ function normalize(obj) {
let attributes = {};
Object.keys(obj).forEach(key => attributes[cleanKey(key)] = obj[key]);
attributes.ingredients = groupByKeyPrefix('ingredient', attributes);
return {
data: {
@ -38,3 +39,13 @@ function cleanKey(key) {
if (key === 'meal') key = 'name';
return key;
}
function groupByKeyPrefix(keyPrefix, obj) {
let resultingArray = [];
Object.keys(obj).forEach(key => {
let value = obj[key];
if (!value) return;
if (key.startsWith(keyPrefix)) resultingArray.push(value);
});
return resultingArray;
}

View file

@ -9,7 +9,9 @@
{{@meal.name}}
</div>
<p class="text-gray-700 text-base">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
{{#each @meal.ingredients as |ingredient|}}
{{ingredient}}
{{/each}}
</p>
</div>
<div>

View file

@ -8,6 +8,7 @@ export default class MealModel extends Model {
@attr area;
@attr mealThumb;
@attr instructions;
@attr ingredients;
@attr tags;
@attr youtube;
@attr source;