Module: Jets::AssetTagHelper
- Extended by:
- Memoist
- Includes:
- AwsServices, CommonMethods
- Defined in:
- lib/jets/rails_overrides/asset_tag_helper.rb
Overview
Override to prepend stage name when on AWS.
Instance Method Summary collapse
- #asset_path(source, options = {}) ⇒ Object
-
#image_tag(source, options = {}) ⇒ Object
Locally:.
- #javascript_include_tag(*sources, **options) ⇒ Object
- #stylesheet_link_tag(*sources, **options) ⇒ Object
Methods included from AwsServices
#cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sts
Methods included from Jets::AwsServices::StackStatus
#stack_exists?, #stack_in_progress?
Methods included from CommonMethods
Instance Method Details
#asset_path(source, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/jets/rails_overrides/asset_tag_helper.rb', line 35 def asset_path(source, = {}) if on_aws?(source) && asset_folder?(source) # mimic original behavior to get /images in source source = "/images/#{source}" unless source.starts_with?('/') source = "#{s3_public}#{source}" end super end |
#image_tag(source, options = {}) ⇒ Object
Locally:
image_tag("jets.png") => /images/jets.png
image_tag("/images/jets.png") => /images/jets.png
Remotely:
image_tag("jets.png") => https://s3-us-west-2.amazonaws.com/demo-dev-s3bucket-1kih4n2te0n66/jets/public/images/jets.png
25 26 27 28 29 30 31 32 33 |
# File 'lib/jets/rails_overrides/asset_tag_helper.rb', line 25 def image_tag(source, = {}) # mimic original behavior to get /images in source source = "/images/#{source}" unless source.starts_with?('/') if on_aws?(source) source = "#{s3_public}#{source}" end super end |
#javascript_include_tag(*sources, **options) ⇒ Object
7 8 9 10 |
# File 'lib/jets/rails_overrides/asset_tag_helper.rb', line 7 def javascript_include_tag(*sources, **) sources = sources.map { |s| s3_public_url(s, :javascripts) } super end |
#stylesheet_link_tag(*sources, **options) ⇒ Object
12 13 14 15 |
# File 'lib/jets/rails_overrides/asset_tag_helper.rb', line 12 def stylesheet_link_tag(*sources, **) sources = sources.map { |s| s3_public_url(s, :stylesheets) } super end |