Sha256: 6f56ca9dfec5da780a0d0cf93486e223da97087f11ae5842a56c3ac260bbb933

Contents?: true

Size: 492 Bytes

Versions: 4

Compression:

Stored size: 492 Bytes

Contents

require "json"

class Hypernova::BlankRenderer
  def initialize(job)
    @job = job
  end

  def render
    <<-HTML
      <div data-hypernova-key="#{key}"></div>
      <script type="application/json" data-hypernova-key="#{key}"><!--#{encode}--></script>
    HTML
  end

  private

  attr_reader :job

  def data
    job[:data]
  end

  def encode
    JSON.generate(data).gsub(/&/, '&amp;').gsub(/>/, '&gt;')
  end

  def key
    name.gsub(/\W/, "")
  end

  def name
    job[:name]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hypernova-1.0.3 lib/hypernova/blank_renderer.rb
hypernova-1.0.2 lib/hypernova/blank_renderer.rb
hypernova-1.0.1 lib/hypernova/blank_renderer.rb
hypernova-1.0.0 lib/hypernova/blank_renderer.rb