lib/hayde/generator.rb in hayde-0.1.12 vs lib/hayde/generator.rb in hayde-0.1.13
- old
+ new
@@ -47,11 +47,11 @@
module Hayde
class Generator
include Hayde::Utils::Files
- attr_accessor :output_dir, :assets_dir, :warnings, :edge, :force, :layout
+ attr_accessor :output_dir, :assets_dir, :warnings, :edge, :force, :layout, :page_title_prefix
filelist_attribute :sources
GUIDES_RE = /\.(?:textile|html\.erb)$/
def initialize
@@ -78,10 +78,11 @@
root_dir = Rails.root if defined? Rails
root_dir ||= Dir.pwd
@layout = 'layout'
@output_dir = File.join(root_dir, 'docs', 'guides')
@assets_dir = File.join(root_dir, 'guides', 'assets')
+ @page_title_prefix = 'Guides: '
end
def generate_guides
sources.each do |source|
output = output_file_for(source)
@@ -141,13 +142,13 @@
end
end
def set_header_section(body, view)
new_body = body.gsub(/(.*?)endprologue\./m, '').strip
- header = $1
+ header = $1 || ''
header =~ /h2\.(.*)/
- page_title = "Framework Guides: #{$1.strip}"
+ page_title = "#{page_title_prefix}#{$1.strip}"
header = textile(header)
view.content_for(:page_title) { page_title.html_safe }
view.content_for(:header_section) { header.html_safe }