Sha256: 44520be30fb9e4789942b47bd9c869475cf77682e2b4f7f679e22de9b1c22d4f
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true module Bridgetown class Converter < Plugin class << self attr_accessor :extname_list # Converters can provide one or more extensions they accept. Examples: # # * `input :erb` # * `input %i(xls xlsx)` def input(extnames) extnames = Array(extnames) self.extname_list ||= [] self.extname_list += extnames.map { |e| ".#{e.to_s.downcase}" } end end # Initialize the converter. # # Returns an initialized Converter. def initialize(config = {}) @config = config end # Logic to do the content conversion. # # @param content [String] content of file (without front matter). # @param convertible [Bridgetown::Document, Bridgetown::Layout, Bridgetown::Resource::Base] # # @return [String] the converted content. def convert(content, convertible = nil) # rubocop:disable Lint/UnusedMethodArgument content end # Does the given extension match this converter's list of acceptable extensions? # # @param [String] ext # The file's extension (including the dot) # # @return [Boolean] Whether the extension matches one in the list def matches(ext) (self.class.extname_list || []).include?(ext.downcase) end # You can override this in Converter subclasses as needed. Default is ".html" # # @param [String] ext # The extension of the original file # # @return [String] The output file extension (including the dot) def output_ext(_ext) ".html" end def inspect "#<#{self.class}#{self.class.extname_list ? " #{self.class.extname_list.join(", ")}" : nil}>" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bridgetown-core-0.20.0 | lib/bridgetown-core/converter.rb |