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

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

Direct Known Subclasses

JavascriptIncludeTag, StylesheetIncludeTag

Constant Summary

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 ActiveSupport::Concern

#append_features, extended, #included

Methods included from CaptureHelper

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

Constructor Details

- (AssetIncludeTag) initialize(config, asset_paths)

A new instance of AssetIncludeTag



20
21
22
23
# File 'actionpack/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

- (Object) asset_paths (readonly)

Returns the value of attribute asset_paths



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

def asset_paths
  @asset_paths
end

- (Object) config (readonly)

Returns the value of attribute config



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

def config
  @config
end

Class Method Details

+ (Object) inherited(base)



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

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

Instance Method Details

- (Object) asset_name

Raises:

  • (NotImplementedError)


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

def asset_name
  raise NotImplementedError
end

- (Object) asset_tag(source, options)

Raises:

  • (NotImplementedError)


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

def asset_tag(source, options)
  raise NotImplementedError
end

- (Object) custom_dir

Raises:

  • (NotImplementedError)


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

def custom_dir
  raise NotImplementedError
end

- (Object) extension

Raises:

  • (NotImplementedError)


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

def extension
  raise NotImplementedError
end

- (Object) include_tag(*sources)



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'actionpack/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