parsley/app/views/recipes/show.json.jbuilder

35 lines
888 B
Plaintext
Raw Normal View History

2018-04-02 11:21:35 -05:00
json.cache_root! [@recipe] do
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.extract! @recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.rendered_steps MarkdownProcessor.render(@recipe.step_text)
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.tags @recipe.tag_names
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.ingredients @recipe.recipe_ingredients do |ri|
json.extract! ri, :id, :ingredient_id, :display_name, :name, :quantity, :units, :preparation, :sort_order
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.ingredient do
if ri.ingredient.nil?
json.null!
else
json.extract! ri.ingredient, :id, :name, :density, :notes
end
2018-04-01 21:43:23 -05:00
end
2018-04-02 11:21:35 -05:00
json._destroy false
2018-04-01 21:43:23 -05:00
end
2018-04-02 11:21:35 -05:00
json.nutrition_data do
json.errors @recipe.nutrition_data.errors
2018-04-01 21:43:23 -05:00
2018-04-02 11:21:35 -05:00
json.nutrients NutritionData::NUTRIENTS.select { |_, v| v.present? } do |name, label|
json.name name
json.label label
json.value @recipe.nutrition_data.send(name)
end
2018-04-01 21:43:23 -05:00
end
2018-04-02 11:21:35 -05:00
end