Sha256: 233e286d0ede42c3537491f607066fddca00e3ab4d4bdfa753b9accd3c109b6c
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
module Ui class ComponentGenerator < Rails::Generators::NamedBase source_root File.expand_path("../templates", __FILE__) def create_component_files if class_path.empty? destination_js = "app/assets/javascripts/application/components" destination_css = "app/assets/stylesheets/application/components" destination_html = "app/views/vue_components" template_js = "javascript.js.erb" template_css = "stylesheet.scss.erb" import_path = "vue_components" @component_id = "v-comp-#{file_name}-template" @component_class = "v-comp-#{file_name}" else src_folder = class_path.join("/").pluralize destination_js = File.join("app/assets/javascripts/application/views", src_folder, "templates") destination_css = File.join("app/assets/stylesheets/application/views", src_folder, "templates") destination_html = File.join("app/views", src_folder, "templates") template_js = "page_javascript.js.erb" template_css = "page_stylesheet.scss.erb" @page_name = src_folder import_path = "#{src_folder}/templates" @component_id = "v-#{@page_name}-#{file_name}-template" @component_class = "v-#{@page_name}-#{file_name}" end template_html = "template.html.erb" @component_name = file_name.camelize(:lower) template template_js, File.join(destination_js, "#{file_name}.js") template template_css, File.join(destination_css, "#{file_name}.scss") template template_html, File.join(destination_html, "_#{file_name}.html") puts puts "\tAdd to your views with: <%= render \"#{import_path}/#{file_name}\" %>" puts end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codelation_ui-1.0.57 | lib/generators/ui/component/component_generator.rb |