class Alchemy::Generators::ElementsGenerator

Public Instance Methods

create_partials() click to toggle source
# File lib/generators/alchemy/elements/elements_generator.rb, line 11
def create_partials
  @elements = load_alchemy_yaml("elements.yml")
  return unless @elements

  @elements.each do |element|
    @element = element
    @ingredients = element["ingredients"] || []
    @element_name = element_name(element)
    conditional_template "view.html.#{template_engine}", "#{elements_dir}/_#{@element_name}.html.#{template_engine}"
  end
end

Private Instance Methods

element_name(element) click to toggle source
# File lib/generators/alchemy/elements/elements_generator.rb, line 29
def element_name(element)
  if Alchemy::Element::NAME_REGEXP.match?(element["name"])
    element["name"].underscore
  else
    raise "Element name '#{element["name"]}' has wrong format. Only lowercase and non whitespace characters allowed."
  end
end
elements_dir() click to toggle source
# File lib/generators/alchemy/elements/elements_generator.rb, line 25
def elements_dir
  @_elements_dir ||= "app/views/alchemy/elements"
end