Class: Epuber::Compiler::FileTypes::BadeFile

Inherits:
XHTMLFile show all
Defined in:
lib/epuber/compiler/file_types/bade_file.rb

Instance Attribute Summary

Attributes inherited from XHTMLFile

#toc_item

Attributes inherited from SourceFile

#abs_source_path, #file_request, #source_path

Attributes inherited from AbstractFile

#destination_path, #final_destination_path, #group, #path_type, #pkg_destination_path, #properties

Instance Method Summary collapse

Methods inherited from XHTMLFile

#common_process, #default_styles, #load_source

Methods inherited from SourceFile

#default_file_copy, #initialize, #write_compiled, #write_processed

Methods inherited from AbstractFile

#==, file_copy, file_copy!, file_copy?, write_to_file, write_to_file!, write_to_file?

Constructor Details

This class inherits a constructor from Epuber::Compiler::FileTypes::SourceFile

Instance Method Details

#process(compilation_context) ⇒ Object

Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/epuber/compiler/file_types/bade_file.rb', line 14

def process(compilation_context)
  target = compilation_context.target
  book = compilation_context.book
  file_resolver = compilation_context.file_resolver

  bade_content = load_source(compilation_context)

  variables = {
    __book: book,
    __target: target,
    __file_resolver: file_resolver,
    __file: self,
    __toc_item: toc_item,
    __const: Hash.new { |_hash, key| UI.warning("Undefined constant with key `#{key}`", location: caller_locations[0]) }.merge!(target.constants),
  }

  xhtml_content = Bade::Renderer.from_source(bade_content, source_path)
                                .with_locals(variables)
                                .render(new_line: '', indent: '')

  write_compiled(common_process(xhtml_content, compilation_context))
end