Class: Locomotive::Wagon::Generators::Snippet
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Locomotive::Wagon::Generators::Snippet
- Includes:
- CLI::ForceColor, Thor::Actions
- Defined in:
- lib/locomotive/wagon/generators/snippet.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from CLI::ForceColor
Class Method Details
.source_root ⇒ Object
41 42 43 |
# File 'lib/locomotive/wagon/generators/snippet.rb', line 41 def self.source_root File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'generators', 'snippet') end |
Instance Method Details
#apply_locales? ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/wagon/generators/snippet.rb', line 17 def apply_locales? self.locales.shift # remove the default locale unless self.locales.empty? unless yes?('Do you want to generate files for each locale?') self.locales = [] end end end |
#create_snippet ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/locomotive/wagon/generators/snippet.rb', line 27 def create_snippet _slug = slug.clone.downcase.gsub(/[-]/, '_') = { slug: _slug, translated: false } file_path = File.join(snippets_path, _slug) template "template.liquid.tt", "#{file_path}.liquid", self.locales.each do |locale| [:translated] = true template "template.liquid.tt", "#{file_path}.#{locale}.liquid", end end |