Sha256: 14ed8cd8fca48d49fbd9a384e3665e0375bf8cb50e5a1fb5cc113de18bad55b5

Contents?: true

Size: 932 Bytes

Versions: 36

Compression:

Stored size: 932 Bytes

Contents

# @author Mike Bland (michael.bland@gsa.gov)

require 'jekyll/static_file'
require 'liquid'

module GuidesStyle18F
  class Assets
    SOURCE = File.realpath File.join(__FILE__, '..', '..', '..')
    BEGIN_PATH = SOURCE.size + File::SEPARATOR.size

    def self.copy_to_site(site)
      Dir.glob File.join(SOURCE, 'assets', '**', '*') do |asset|
        next unless File.file? asset
        asset = asset[BEGIN_PATH..-1]
        site.static_files << ::Jekyll::StaticFile.new(
          site, SOURCE, File.dirname(asset), File.basename(asset))
      end
    end
  end

  class AssetRootTag < ::Liquid::Tag
    ::Liquid::Template.register_tag 'guides_style_18f_asset_root', self

    def render(context)
      self.class.do_render context
    end

    def self.do_render(context)
      @asset_root ||= begin
        config = context.registers[:site].config
        config['asset_root'] || config['baseurl']
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
guides_style_18f-0.1.13 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.12 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.11 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.10 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.9 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.8 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.7 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.6 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.5 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.4 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.3 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.2 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.1 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.0 lib/guides_style_18f/assets.rb
guides_style_18f-0.0.1 lib/guides_style_18f/assets.rb
guides_style_18f-0.0.0 lib/guides_style_18f/assets.rb