Class: HJ7::Jammit::Tags::AssetTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/hj7/jammit.rb

Direct Known Subclasses

IncludeCssTag, IncludeJsTag

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, name, kind, tokens) ⇒ AssetTag

Returns a new instance of AssetTag.



33
34
35
36
37
38
# File 'lib/hj7/jammit.rb', line 33

def initialize(tag_name, name, kind, tokens)
  super tag_name, name, tokens
  @name   = name.to_s.strip
  @kind   = kind.to_s
  @config = File.exists?("_assets.yml") ? YAML.load_file("_assets.yml") : {}
end

Instance Method Details

#render(context) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/hj7/jammit.rb', line 40

def render(context)
  if Jekyll::ENV == "production"
    markup "/assets/#{name_with_ext}"
  else
    (assets_for_name.map do |asset|
      markup "#{@path}/#{asset}"
    end).join("\n")
  end
end