Class: Locomotive::Wagon::Generators::Page
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Locomotive::Wagon::Generators::Page
- Includes:
- CLI::ForceColor, Thor::Actions
- Defined in:
- lib/locomotive/wagon/generators/page.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from CLI::ForceColor
Class Method Details
.source_root ⇒ Object
36 37 38 |
# File 'lib/locomotive/wagon/generators/page.rb', line 36 def self.source_root File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'generators', 'page') end |
Instance Method Details
#create_page ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/locomotive/wagon/generators/page.rb', line 16 def create_page segments = self.slug.split('/').find_all { |segment| segment != '' } max_segments = segments.size while segment = segments.pop do = self.(slug: segment, translated: false) file_path = File.join(pages_path, segments, segment) # the content type option is never deleted for the first segment (the requested template) .delete(:content_type) unless segments.size == (max_segments - 1) template 'template.liquid.tt', "#{file_path}.liquid", self.other_locales.each do |locale| [:translated] = true template 'template.liquid.tt', "#{file_path}.#{locale}.liquid", end end end |