Module: SciolyFF::Interpreter::HTML

Included in:
SciolyFF::Interpreter
Defined in:
lib/sciolyff/interpreter/html.rb

Overview

Grants ability to convert a SciolyFF file into stand-alone HTML and other formats (YAML, JSON)

Defined Under Namespace

Classes: Helpers

Instance Method Summary collapse

Instance Method Details

#htmlObject



11
12
13
14
15
16
17
18
19
# File 'lib/sciolyff/interpreter/html.rb', line 11

def html
  helpers = Interpreter::HTML::Helpers.new
  ERB.new(
    helpers.template,
    trim_mode: '<>'
  ).result(helpers.get_binding(self))
     .gsub(/^\s*$/, '')   # remove empty lines
     .gsub(/\s+$/, '')    # remove trailing whitespace
end

#json(pretty: false) ⇒ Object



25
26
27
28
29
# File 'lib/sciolyff/interpreter/html.rb', line 25

def json(pretty: false)
  return JSON.pretty_generate(@rep) if pretty

  @rep.to_json
end

#yamlObject



21
22
23
# File 'lib/sciolyff/interpreter/html.rb', line 21

def yaml
  stringify_keys(@rep).to_yaml
end