Class: Cmsimple::SnippetGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Cmsimple::SnippetGenerator
- Defined in:
- lib/generators/cmsimple/snippet/snippet_generator.rb
Instance Method Summary collapse
-
#add_to_snippet_list ⇒ Object
this is gross need to write something that acts like template but just returns the result.
- #create_cell_file ⇒ Object
- #create_view_files ⇒ Object
Instance Method Details
#add_to_snippet_list ⇒ Object
this is gross need to write something that acts like template but just returns the result
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/cmsimple/snippet/snippet_generator.rb', line 27 def add_to_snippet_list html = '' if handler.to_sym == :haml html = <<-HTML %li(data-filter="#{class_name.underscore}, snippet, name") %img(alt="#{class_name.humanize} Snippet" data-snippet="#{class_name.underscore}" src="/assets/toolbar/snippets.png") %h4>#{class_name.humanize} .description A one or two line long description of what this snippet does. HTML elsif handler.to_sym == :erb html = <<-HTML <li data-filter="#{class_name.underscore}, snippet, name"> <img alt="#{class_name.humanize} Snippet" data-snippet="#{class_name.underscore}" src="/assets/toolbar/snippets.png"> <h4>#{class_name.humanize}</h4> <div class="description"> A one or two line long description of what this snippet does.</div> </li> HTML end append_to_file "app/views/cmsimple/_snippet_list.html.#{handler}", html end |
#create_cell_file ⇒ Object
11 12 13 |
# File 'lib/generators/cmsimple/snippet/snippet_generator.rb', line 11 def create_cell_file template 'cell.rb', "#{base_path}_cell.rb" end |
#create_view_files ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/generators/cmsimple/snippet/snippet_generator.rb', line 15 def create_view_files file = "display.html.#{handler}" @path = File.join(base_path, file) template file, @path @fields = fields file = "options.html.#{handler}" @path = File.join(base_path, file) template file, @path end |