Class: Beamlet::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/beamlet/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Generator

Returns a new instance of Generator.



5
6
7
# File 'lib/beamlet/generator.rb', line 5

def initialize(opts = {})
  @opts = default_opts.merge(opts)
end

Instance Method Details

#documentObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/beamlet/generator.rb', line 9

def document
  titleframe = @opts[:titleframe] ? Templates::TITLE_FRAME : ""
  Templates::DOCUMENT % {
    theme:      @opts[:theme],
    title:      escape(@opts[:title]),
    author:     escape(@opts[:author]),
    date:       escape(@opts[:date]),
    titleframe: titleframe,
    body:       "% --- vos frames ici ---"
  }
end

#frameObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/beamlet/generator.rb', line 27

def frame
  body = build_body
  body = split_into_columns(body, @opts[:splits]) if @opts[:splits] && @opts[:splits] > 1

  options = []
  options << "fragile" if @opts[:fragile]
  options << "allowframebreaks" if @opts[:allowframebreaks]
  opt_str = options.empty? ? "" : "[#{options.join(',')}]"

  Templates::FRAME % {
    options: opt_str,
    title:   escape(@opts[:frame_title] || ""),
    body:    indent(body, 2)
  }
end

#partObject



21
22
23
24
25
# File 'lib/beamlet/generator.rb', line 21

def part
  Templates::PART % {
    title: escape(@opts[:part_title] || "Partie")
  }
end