

json.extract! recipe, :id, :name, :rating, :yields, :total_time, :active_time, :created_at, :updated_at, :step_text, :converted_scale, :converted_system, :converted_unit

json.rendered_steps MarkdownProcessor.render(recipe.step_text)

json.tags recipe.tag_names

json.ingredients recipe.recipe_ingredients do |ri|
  json.extract! ri, :id, :ingredient_id, :display_name, :name, :quantity, :units, :preparation, :sort_order

  json.ingredient do
    if ri.ingredient.nil?
      json.null!
    else
      json.extract! ri.ingredient, :id, :name, :density, :notes
    end
  end

  json._destroy false
end

json.nutrition_data do
  json.errors recipe.nutrition_data.errors

  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

end