Sha256: f92d6f3470bbbe3d7e5d29d48a12c23216ecbee8592c02f61beacdf72b7c9fc6

Contents?: true

Size: 785 Bytes

Versions: 30

Compression:

Stored size: 785 Bytes

Contents

module Nexmo
  module OAS
    module Renderer
      module Filters
        class Partial < Banzai::Filter
          def call(input)
            input.gsub(/```partial(.+?)```/m) do |_s|
              config = YAML.safe_load($1)
              content = File.read(config['source'])

              active = options[:code_language] ? options[:code_language].key == config['platform'] : false

              if config['platform']
                <<~HEREDOC
                  <div class="js-platform" data-platform="#{config['platform']}" data-active="#{active}">
                    #{content.render_markdown}
                  </div>
                HEREDOC
              else
                content
              end
            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/partial.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.5.0 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.4.1 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.4.0 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.3.7 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.3.6 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.3.5 lib/nexmo/oas/renderer/filters/partial.rb
nexmo-oas-renderer-0.3.4 lib/nexmo/oas/renderer/filters/partial.rb