# Copyright (c) 2009 Narihiro Nakamura require 'erb' class HTMLLayout include ERB::Util def initialize(params, template) @body = params['body'] @title = params['title'] @toc = params['toc'] @next = params['next'] @prev = params['prev'] @builder = params['builder'] @template = template end attr_reader :body, :title, :toc def next_chapter if @next.present? "#{h @builder.compile_inline @next.title}" else "" end end def prev_chapter if @prev.present? "#{h @builder.compile_inline @prev.title}" else "" end end def result if File.exist?(@template) return ERB.new(IO.read(@template)).result(binding) else return @src end end end