Sha256: 4da1c5e78d53a38c0a7d7e908473dab70c4be61685e9dc9f0e7cddb0b8039a03

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

module Jekyll
  module AssetsPlugin
    class Renderer

      STYLESHEET = '<link rel="stylesheet" href="%s">'
      JAVASCRIPT = '<script src="%s"></script>'


      def initialize context, logical_path
        @site = context.registers[:site]
        @path = logical_path.strip
      end


      def render_asset
        @site.assets[@path].to_s
      end


      def render_asset_path
        @site.asset_path @path
      end


      def render_javascript
        @path << ".js" if File.extname(@path).empty?
        render_tag JAVASCRIPT
      end


      def render_stylesheet
        @path << ".css" if File.extname(@path).empty?
        render_tag STYLESHEET
      end


      protected


      def render_tag template
        asset = @site.assets[@path]
        (@site.assets_config.debug ? asset.to_a : [asset]).map{ |a|
          template % AssetPath.new(a).to_s
        }.join("\n")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-assets-0.7.1 lib/jekyll/assets_plugin/renderer.rb