Sha256: cff89ee9f653008cf245075518c11fd19ac7c73c9aff0aa53b55acb54a571382

Contents?: true

Size: 835 Bytes

Versions: 30

Compression:

Stored size: 835 Bytes

Contents

require_relative '../models/tutorial'
require 'banzai'
require 'yaml'

module Nexmo
  module OAS
    module Renderer
      module Filters
        class Tutorials < Banzai::Filter
          def call(input)
            input.gsub(/```tutorials(.+?)```/m) do |_s|
              config = YAML.safe_load($1)
              @product = config['product']
              @tutorials = Models::Tutorial.by_product(@product)

              # Default to plain layout, but allow people to override it
              config['layout'] = 'list/plain' unless config['layout']

              erb = File.read("#{API.root}/views/tutorials/#{config['layout']}.html.erb")
              html = ERB.new(erb).result(binding)
              "FREEZESTART#{Base64.urlsafe_encode64(html)}FREEZEEND"
            end
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.7.1 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.5.0 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.4.1 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.4.0 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.3.7 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.3.6 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.3.5 lib/nexmo/oas/renderer/filters/tutorials.rb
nexmo-oas-renderer-0.3.4 lib/nexmo/oas/renderer/filters/tutorials.rb