Class: Katapult::Generators::HamlGenerator

Inherits:
Katapult::Generator show all
Defined in:
lib/generators/katapult/haml/haml_generator.rb

Instance Attribute Summary

Attributes inherited from Katapult::Generator

#element

Instance Method Summary collapse

Methods inherited from Katapult::Generator

#initialize

Constructor Details

This class inherits a constructor from Katapult::Generator

Instance Method Details

#create_form_partial_if_neededObject



32
33
34
35
36
37
38
39
40
# File 'lib/generators/katapult/haml/haml_generator.rb', line 32

def create_form_partial_if_needed
  _form_actions = (actions.map(&:name) & %w[new edit])

  if _form_actions.any?
    file_name = '_form.html.haml'

    create_view file_name, File.join(views_path, file_name)
  end
end

#create_rails_standard_action_viewsObject



24
25
26
27
28
29
30
# File 'lib/generators/katapult/haml/haml_generator.rb', line 24

def create_rails_standard_action_views
  actions.select{ |a| a.get? && WUI::RAILS_ACTIONS.include?(a.name) }.each do |action|
    file_name = "#{action.name}.html.haml"

    create_view file_name, File.join(views_path, file_name)
  end
end

#create_views_directoryObject



20
21
22
# File 'lib/generators/katapult/haml/haml_generator.rb', line 20

def create_views_directory
  FileUtils.mkdir_p views_path
end

#create_views_for_custom_actionsObject



42
43
44
45
46
47
# File 'lib/generators/katapult/haml/haml_generator.rb', line 42

def create_views_for_custom_actions
  wui.custom_actions.select(&:get?).each do |action|
    @action = action # Make the action object accessible in templates
    create_view 'custom_action.html.haml', File.join(views_path, "#{action.name}.html.haml")
  end
end

#generate_integration_testsObject



49
50
51
52
53
# File 'lib/generators/katapult/haml/haml_generator.rb', line 49

def generate_integration_tests
  if wui.model.present?
    Generators::CucumberFeaturesGenerator.new(wui.model).invoke_all
  end
end

#install_application_layoutObject



14
15
16
17
18
# File 'lib/generators/katapult/haml/haml_generator.rb', line 14

def install_application_layout
  remove_file 'app/views/layouts/application.html.erb'
  template 'app/views/layouts/application.html.haml'
  template 'app/views/layouts/_flashes.html.haml'
end