Skip to content

Commit

Permalink
wip: render ingredient editors
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Apr 10, 2021
1 parent 34eb77f commit 66d6f03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/decorators/alchemy/element_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ def contents
end
end

# Returns ingredient editor instances for defined ingredients
#
# Creates ingredient on demand if the ingredient is not yet present on the element
#
# @return Array<Alchemy::IngredientEditor>
def ingredients
element.definition.fetch(:ingredients, []).map do |ingredient|
Alchemy::IngredientEditor.new(find_or_create_ingredient(ingredient[:role]))
end
end

# CSS classes for the element editor partial.
def css_classes
[
Expand Down

0 comments on commit 66d6f03

Please sign in to comment.