Class: ActionView::Helpers::AssetTagHelper::AssetIncludeTag

Inherits:
Object
  • Object
show all
Includes:
TagHelper
Defined in:
lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb

Direct Known Subclasses

JavascriptIncludeTag, StylesheetIncludeTag

Constant Summary

Constants included from TagHelper

TagHelper::BOOLEAN_ATTRIBUTES, TagHelper::PRE_CONTENT_STRINGS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TagHelper

#cdata_section, #content_tag, #escape_once, #tag

Methods included from CaptureHelper

#capture, #content_for, #content_for?, #flush_output_buffer, #provide, #with_output_buffer

Constructor Details

#initialize(config, asset_paths) ⇒ AssetIncludeTag

Returns a new instance of AssetIncludeTag.



20
21
22
23
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 20

def initialize(config, asset_paths)
  @config = config
  @asset_paths = asset_paths
end

Instance Attribute Details

#asset_pathsObject (readonly)

Returns the value of attribute asset_paths.



13
14
15
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 13

def asset_paths
  @asset_paths
end

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 13

def config
  @config
end

Class Method Details

.inherited(base) ⇒ Object



16
17
18
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 16

def self.inherited(base)
  base.expansions = { }
end

Instance Method Details

#asset_nameObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 25

def asset_name
  raise NotImplementedError
end

#asset_tag(source, options) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 37

def asset_tag(source, options)
  raise NotImplementedError
end

#custom_dirObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 33

def custom_dir
  raise NotImplementedError
end

#extensionObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 29

def extension
  raise NotImplementedError
end

#include_tag(*sources) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb', line 41

def include_tag(*sources)
  options = sources.extract_options!.stringify_keys
  concat  = options.delete("concat")
  cache   = concat || options.delete("cache")
  recursive = options.delete("recursive")

  if concat || (config.perform_caching && cache)
    joined_name = (cache == true ? "all" : cache) + ".#{extension}"
    joined_path = File.join((joined_name[/^#{File::SEPARATOR}/] ? config.assets_dir : custom_dir), joined_name)
    unless config.perform_caching && File.exists?(joined_path)
      write_asset_file_contents(joined_path, compute_paths(sources, recursive))
    end
    asset_tag(joined_name, options)
  else
    sources = expand_sources(sources, recursive)
    ensure_sources!(sources) if cache
    sources.collect { |source| asset_tag(source, options) }.join("\n").html_safe
  end
end