Sha256: 4f9430c34133a83684ce152a764fcd89d0da2f4b4b55bfd39e1b9d1d4c0de40c

Contents?: true

Size: 928 Bytes

Versions: 2

Compression:

Stored size: 928 Bytes

Contents

module Jekyll
  module Assets
    module Helpers
      class << self
        def has_javascript?
          require "execjs"
          if block_given?
            yield
          end
        rescue LoadError, ExecJS::RuntimeUnavailable
          Jekyll.logger.debug("ExecJS or JS Runtime not available." \
            " Skipping loading of library.")
        end

        def try_require(file)
          require file
          if block_given?
            yield
          end
        rescue LoadError
          return nil
        end

        def try_require_if_javascript?(file)
          ["execjs", file].map(&method(:require))
          if block_given?
            yield
          end
        rescue LoadError, ExecJS::RuntimeUnavailable
          Jekyll.logger.debug("ExecJS, JS Runtime or `#{file}' not available." \
            " Skipping the loading of libraries.")
          return
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-assets-2.0.0.pre.beta2 lib/jekyll/assets/helpers.rb
jekyll-assets-2.0.0.pre.beta1 lib/jekyll/assets/helpers.rb