Class: Thorax::Generators::ViewGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Thorax::Generators::ViewGenerator
show all
- Includes:
- ResourceHelpers
- Defined in:
- lib/generators/thorax/view/view_generator.rb
Constant Summary
collapse
- RESERVED_JS_WORDS =
%W{
break case catch continue debugger default delete do else finally for
function if in instanceof new return switch this throw try typeof var void while with
}
Instance Method Summary
collapse
#application_name, #collection_namespace, #hbs, #js_app_name, #model_namespace, #plural_model_name, #router_namespace, #singular_model_name, #template_path, #thorax_path, #uncapitalize, #view_namespace
Instance Method Details
#create_view_files ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/generators/thorax/view/view_generator.rb', line 27
def create_view_files
actions.each do |action|
@action = action
@view_path = File.join(thorax_path, "views", plural_name, "#{@action}.js.coffee")
@hbs_path = File.join(template_path, plural_name, "#{@action}.hbs")
template "view.coffee", @view_path
template "template.hbs", @hbs_path
end
end
|
#validate_no_reserved_words ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/generators/thorax/view/view_generator.rb', line 18
def validate_no_reserved_words
actions.each do |action|
if RESERVED_JS_WORDS.include? action
raise Thor::Error, "The name '#{action}' is reserved by javascript " <<
"Please choose an alternative action name and run this generator again."
end
end
end
|