Class: Occams::Content::Tag::Audio
- Inherits:
-
Occams::Content::Tag
- Object
- Occams::Content::Tag
- Occams::Content::Tag::Audio
- Defined in:
- lib/occams/content/tags/audio.rb
Overview
Tag for injecting HTML5 audio player. Example tag:
{{ cms:audio "path/to/audio", style: "height: 22px; width: 80%" }}
This expands into:
<audio controls src="path/to/audio"></audio>
To customize your player style, add a ‘audioplayer’ class to your CSS, e.g .audioplayer
border-radius: 6px
height: 22px
width: 60%
margin: 2px 0 2px 8px
padding: 0
and/or pass in style overrides with the ‘style’ parameter
Instance Attribute Summary collapse
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Occams::Content::Tag
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(context:, params: [], source: nil) ⇒ Audio
constructor
A new instance of Audio.
Methods inherited from Occams::Content::Tag
Constructor Details
#initialize(context:, params: [], source: nil) ⇒ Audio
Returns a new instance of Audio.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/occams/content/tags/audio.rb', line 19 def initialize(context:, params: [], source: nil) super = params. @path = params[0] @style = ['style'] return if @path.present? raise Error, 'Missing path for audio tag' end |
Instance Attribute Details
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
17 18 19 |
# File 'lib/occams/content/tags/audio.rb', line 17 def locals @locals end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/occams/content/tags/audio.rb', line 17 def path @path end |
Instance Method Details
#content ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/occams/content/tags/audio.rb', line 30 def content format( '<style>.audioplayer {%<style>s}</style><audio controls class="audioplayer" src=%<path>p></audio>', path: @path, style: @style ) end |