Really fixing extensionless file support
Pieced together a fix using Regex and `File.extname` from http://github.com/vast/rocco Closes GH-24.
This commit is contained in:
parent
515966dcc9
commit
ba93d23634
@ -90,7 +90,7 @@ end
|
||||
# Run each file through Rocco and write output.
|
||||
sources.each do |filename|
|
||||
rocco = Rocco.new(filename, sources, options)
|
||||
dest = File.join(output_dir, (filename.split('.')[0..-2].empty? ? filename : filename.split('.')[0..-2].join('.')) + '.html')
|
||||
dest = File.join(output_dir, filename.sub(Regexp.new("#{File.extname(filename)}$"),".html"))
|
||||
puts "rocco: #{filename} -> #{dest}"
|
||||
FileUtils.mkdir_p File.dirname(dest)
|
||||
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||
|
@ -40,7 +40,7 @@ class Rocco::Layout < Mustache
|
||||
{
|
||||
:path => source,
|
||||
:basename => File.basename(source),
|
||||
:url => File.basename(source).split('.')[0..-2].join('.') + '.html'
|
||||
:url => source.sub( Regexp.new( "#{File.extname(source)}$"), ".html" )
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ class Rocco
|
||||
# Run over the source file list, constructing destination filenames
|
||||
# and defining file tasks.
|
||||
@sources.each do |source_file|
|
||||
dest_file = File.basename(source_file).split('.')[0..-2].join('.') + '.html'
|
||||
dest_file = source_file.sub(Regexp.new("#{File.extname(source_file)}$"), ".html")
|
||||
define_file_task source_file, "#{@dest}#{dest_file}"
|
||||
|
||||
# If `rake/clean` was required, add the generated files to the list.
|
||||
@ -103,6 +103,7 @@ class Rocco
|
||||
file dest_file => prerequisites do |f|
|
||||
verbose { puts "rocco: #{source_file} -> #{dest_file}" }
|
||||
rocco = Rocco.new(source_file, @sources.to_a, @options)
|
||||
FileUtils.mkdir_p(File.dirname(dest_file))
|
||||
File.open(dest_file, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||
end
|
||||
task @name => dest_file
|
||||
|
Loading…
Reference in New Issue
Block a user