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.



93
94
95
96
97
98
# File 'lib/bookfile/book/book.rb', line 93

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)


101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/bookfile/book/book.rb', line 101

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