Sha256: 280d701303bdb9687c099924401096c91d0a2878560750c026f4073188e678c2

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

require 'templater'
require 'middleman/templater+dynamic_renderer.rb'

# Placeholder for any methods the builder needs to abstract to allow feature integration
module Middleman
  class Builder < ::Templater::Generator
    # Define source and desintation
    def self.source_root; Dir.pwd; end
    def destination_root; File.join(Dir.pwd, Middleman::Base.build_dir); end

    # Override template to ask middleman for the correct extension to output
    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::Base.views)}/", "")
                         .gsub("#{File.basename(Middleman::Base.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

    def self.file(name, *args, &block)
      if (args[0] === args[1])
        args[1] = args[0].gsub("#{File.basename(Middleman::Base.views)}/", "")
                         .gsub("#{File.basename(Middleman::Base.public)}/", "")
      end
      super(name, *args, &block)
    end

    def self.init!
      glob! File.basename(Middleman::Base.public), []
      glob! File.basename(Middleman::Base.views),  Middleman::Base.supported_formats
    end
    
    def after_run
    end
  end
  
  module Generators
    extend ::Templater::Manifold
    desc "Build a static site"

    add :build, ::Middleman::Builder
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
middleman-0.10.10 lib/middleman/builder.rb
middleman-0.10.9 lib/middleman/builder.rb
middleman-0.10.8 lib/middleman/builder.rb
middleman-0.10.7 lib/middleman/builder.rb
middleman-0.10.6 lib/middleman/builder.rb
middleman-0.10.5 lib/middleman/builder.rb
middleman-0.10.4 lib/middleman/builder.rb
middleman-0.10.3 lib/middleman/builder.rb
middleman-0.10.2 lib/middleman/builder.rb
middleman-0.10.1 lib/middleman/builder.rb
middleman-0.10.0 lib/middleman/builder.rb
middleman-0.9.23 lib/middleman/builder.rb
middleman-0.9.22 lib/middleman/builder.rb
middleman-0.9.21 lib/middleman/builder.rb
middleman-0.9.20 lib/middleman/builder.rb
middleman-0.9.18 lib/middleman/builder.rb