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-1.0.6 lib/guides_style_18f/assets.rb
guides_style_18f-1.0.4 lib/guides_style_18f/assets.rb
guides_style_18f-1.0.3 lib/guides_style_18f/assets.rb
guides_style_18f-1.0.2 lib/guides_style_18f/assets.rb
guides_style_18f-1.0.1 lib/guides_style_18f/assets.rb
guides_style_18f-1.0.0 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.9 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.8 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.7 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.6 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.5 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.4 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.3 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.2 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.1 lib/guides_style_18f/assets.rb
guides_style_18f-0.4.0 lib/guides_style_18f/assets.rb
guides_style_18f-0.3.0 lib/guides_style_18f/assets.rb
guides_style_18f-0.2.0 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.15 lib/guides_style_18f/assets.rb
guides_style_18f-0.1.14 lib/guides_style_18f/assets.rb