سؤال

This is the HTML audio tag:

<audio controls autoplay loop muted>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>

How is this written in Slim code, including the control, auto play and loop attributes?

هل كانت مفيدة؟

المحلول

You can get the empty attributes with boolean attributes in Slim. I guess your HTML snippet translates to something like this:

audio controls=true autoplay=true loop=true muted=true
  source src="horse.ogg" type="audio/ogg"
  source src="horse.mp3" type="audio/mpeg"

  | Your browser does not support the audio tag.

or shorter

audio(controls autoplay loop muted)
  …

نصائح أخرى

If you are using Rails, you can also use the audio_tag helper: https://apidock.com/rails/ActionView/Helpers/AssetTagHelper/audio_tag

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top