Class: Middleman::Builder
- Inherits:
-
Templater::Generator
- Object
- Templater::Generator
- Middleman::Builder
- Defined in:
- lib/middleman/builder.rb
Constant Summary collapse
- @@template_extensions =
Support all Tilt-enabled templates and treat js like a template
::Tilt.mappings.keys << "js"
Class Method Summary collapse
- .file(name, *args, &block) ⇒ Object
- .init! ⇒ Object
-
.source_root ⇒ Object
Define source and desintation.
-
.template(name, *args, &block) ⇒ Object
Override template to ask middleman for the correct extension to output.
Instance Method Summary collapse
Class Method Details
.file(name, *args, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/middleman/builder.rb', line 34 def self.file(name, *args, &block) file_ext = File.extname(args[0]) return unless ::Tilt[file_ext].nil? if (args[0] === args[1]) args[1] = args[0].gsub("#{File.basename(Middleman::Server.views)}/", "").gsub("#{File.basename(Middleman::Server.public)}/", "") end super(name, *args, &block) end |
.init! ⇒ Object
45 46 47 48 |
# File 'lib/middleman/builder.rb', line 45 def self.init! glob! File.basename(Middleman::Server.public), @@template_extensions glob! File.basename(Middleman::Server.views), @@template_extensions end |
.source_root ⇒ Object
Define source and desintation
13 |
# File 'lib/middleman/builder.rb', line 13 def self.source_root; Dir.pwd; end |
.template(name, *args, &block) ⇒ Object
Override template to ask middleman for the correct extension to output
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/middleman/builder.rb', line 17 def self.template(name, *args, &block) return if args[0].include?('layout') args.first.split('/').each do |part| return if part[0,1] == '_' end if (args[0] === args[1]) args[1] = args[0].gsub("#{File.basename(Middleman::Server.views)}/", "").gsub("#{File.basename(Middleman::Server.public)}/", "") if File.extname(args[1]) != ".js" args[1] = args[1].gsub!(File.extname(args[1]), "") if File.basename(args[1]).split('.').length > 2 end end super(name, *args, &block) end |