Class: Landable::Liquid::AssetTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Landable::Liquid::AssetTag
- Includes:
- ActionView::Helpers::AssetTagHelper, Sprockets::Rails::Helper
- Defined in:
- lib/landable/liquid/asset_tags.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#asset_name ⇒ Object
Returns the value of attribute asset_name.
-
#tag_name ⇒ Object
Returns the value of attribute tag_name.
Instance Method Summary collapse
-
#initialize(tag_name, param, tokens) ⇒ AssetTag
constructor
A new instance of AssetTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, param, tokens) ⇒ AssetTag
Returns a new instance of AssetTag.
14 15 16 17 18 |
# File 'lib/landable/liquid/asset_tags.rb', line 14 def initialize(tag_name, param, tokens) @tag_name = tag_name @asset_name = param.strip @tokens = tokens end |
Instance Attribute Details
#asset_name ⇒ Object
Returns the value of attribute asset_name.
6 7 8 |
# File 'lib/landable/liquid/asset_tags.rb', line 6 def asset_name @asset_name end |
#tag_name ⇒ Object
Returns the value of attribute tag_name.
6 7 8 |
# File 'lib/landable/liquid/asset_tags.rb', line 6 def tag_name @tag_name end |
Instance Method Details
#render(context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/landable/liquid/asset_tags.rb', line 20 def render(context) tag_method = tag_name.to_sym tag_method = :image_tag if tag_method == :img_tag # if this matches an application asset, use that if assets_environment[asset_name] send tag_method, asset_name # otherwise, find an asset of our own else asset = lookup_asset context, asset_name = {} [:alt] = asset.description if tag_method == :image_tag send tag_method, asset.public_url, end end |