Class: Bookfile::BookCtx

Inherits:
Object
  • Object
show all
Defined in:
lib/bookfile/book/book.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, book_opts = {}) ⇒ BookCtx

Returns a new instance of BookCtx.



88
89
90
91
92
93
# File 'lib/bookfile/book/book.rb', line 88

def initialize( config, book_opts={} )
  @config  = config
  ## todo: add opts to config ???
  ##  e.g. title, layout, inline ??? - why? why not??
  @builder = BookBuilder.new( config.pages_dir, book_opts )
end

Instance Method Details

#page(name, page_opts = {}) {|ctx| ... } ⇒ Object

change name to path - why, why not??

Yields:

  • (ctx)


96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/bookfile/book/book.rb', line 96

def page( name, page_opts={} )  ## &block
  puts "[BookCtx#page] #{name} opts:#{page_opts.inspect}"

  puts "[BookCtx#page] before yield"
  ctx = PageCtx.new( @config )   ## pass along self (bookctx) as parent
  yield( ctx )  ## same as - ctx.instance_eval( &block )
  puts "[BookCtx#page] after yield"

  @builder.page( name, page_opts ) do |page|
    page.write ctx.content
  end
end