src/Elements/Bundle/DemiFrontendBundle/Resources/views/Accommodation/includes/rating-md.html.twig line 1

Open in your IDE?
  1. <div class="rating rating--md {{ isTextWhite is defined ? 'rating--white': '' }} {{ styleModifier }}">
  2.     <div class="trustyou-logo mb-1"><span class="sr-only">TrustYou Rating</span></div>
  3.     <div class="rating__score">{{ score }}</div>
  4.     <div class="rating__content">
  5.         <div class="rating__text">
  6.             {{ text }}
  7.         </div>
  8.         <div class="rating-stars">
  9.             {# @var (float)#}
  10.             {% set totalRating = score %}
  11.             {% set maxStars = 5 %}
  12.             {#round stars to next .5-step #}
  13.             {% set normalizedTotalRating = (totalRating * 2 | round) / 2 %}
  14.             {# floor normalizedRating to next int #}
  15.             {% set fullTotalStars = normalizedTotalRating | round(0, 'floor') %}
  16.             {% set halfTotalStar = normalizedTotalRating - fullTotalStars > 0 %}
  17.             {% set emptyTotalStars = maxStars - fullTotalStars %}
  18.             {% for s in 1..fullTotalStars %}
  19.                 <span class="rating-star"></span>
  20.             {% endfor %}
  21.             {% if halfTotalStar %}
  22.                 {% set emptyTotalStars = emptyTotalStars - 1 %}
  23.                 <span class="rating-star rating-star--half"></span>
  24.             {% endif %}
  25.             {% if emptyTotalStars > 0 %}
  26.                 {% for e in 1..emptyTotalStars %}
  27.                     <span class="rating-star rating-star--empty"></span>
  28.                 {% endfor %}
  29.             {% endif %}
  30.         </div>
  31.         {% if showReviewCount %}
  32.             <span class="rating__count text-muted">
  33.                  ({{ ratingCount }} {{ ratingCount > 1 ? 'demi.ratings'|trans : 'demi.rating'|trans}})
  34.             </span>
  35.         {% endif %}
  36.     </div>
  37. </div>