You are here

cookie-content-blocker-wrapper.html.twig in Cookie Content Blocker 8

Default theme implementation for the Cookie content blocker wrapper.

The original content is wrapped in a <script> tag with type "text/plain" to prevent browsers from loading content like image pixels.

Available variables:

  • attributes: HTML attributes to be added to the element..
  • show_placeholder: Wheter or not a placeholder is visible to the end user.
  • button_classes: The classes for the button.
  • button_text: The cookie consent change button text.
  • blocked_message: The message to show when content is blocked.
  • original_content: The original content which is not rendered until consent has been given. Note that <script> tags are replaced by a place- holder tag in order to not break the 'text/plain' outer <script> tag.

See also

template_preprocess()

template_process()

File

templates/cookie-content-blocker-wrapper.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for the Cookie content blocker wrapper.
  5. *
  6. * The original content is wrapped in a <script> tag with type "text/plain" to
  7. * prevent browsers from loading content like image pixels.
  8. *
  9. * Available variables:
  10. * - attributes: HTML attributes to be added to the element..
  11. * - show_placeholder: Wheter or not a placeholder is visible to the end user.
  12. * - button_classes: The classes for the button.
  13. * - button_text: The cookie consent change button text.
  14. * - blocked_message: The message to show when content is blocked.
  15. * - original_content: The original content which is not rendered until
  16. * consent has been given. Note that <script> tags are replaced by a place-
  17. * holder tag in order to not break the 'text/plain' outer <script> tag.
  18. *
  19. * @see template_preprocess()
  20. * @see template_process()
  21. */
  22. #}
  23. {%
  24. set blocker_classes = [
  25. 'js-cookie-content-blocker',
  26. 'cookie-content-blocker',
  27. enable_click and not show_button ? 'js-cookie-content-blocker-click-consent-change cookie-content-blocker--click-consent-change',
  28. ]
  29. %}
  30. {%
  31. set button_classes = [
  32. 'button',
  33. 'cookie-content-blocker__button',
  34. 'js-cookie-content-blocker-consent-change-button',
  35. ]
  36. %}
  37. {% if show_placeholder %}
  38. <div{{ attributes.addClass(blocker_classes)}}>
  39. <div class="cookie-content-blocker__message-wrapper">
  40. {% if preview %}
  41. <div class="cookie-content-blocker__preview">
  42. {{ preview }}
  43. </div>
  44. {% endif %}
  45. <div class="cookie-content-blocker__message">
  46. {{ blocked_message }}
  47. </div>
  48. {% if show_button %}
  49. <button{{ attributes.addClass(button_classes)}}>{{ button_text }}</button>
  50. {% endif %}
  51. </div>
  52. {% endif %}
  53. <!-- Begin blocked content -->
  54. {#
  55. Always keep this 'text/plain' <script> wrapper around your original
  56. content. When you are manually wrapping this logic around some content
  57. make sure that your original content does not contain <script> tags,
  58. but <scriptfake> tags instead. They will be swapped automatically when
  59. the necessary cookies are accepted.
  60. #}
  61. <script class="js-cookie-content-blocker-content" type="text/plain">{{ original_content }}</script>
  62. <!-- End blocked content -->
  63. {% if show_placeholder %}
  64. </div>
  65. {% endif %}