У меня есть следующий JS, который нужно загрузить в шаблон Twig.
var modal = document.getElementById('myModal');
var handle
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal and begin countdown
btn.onclick = function() {
modal.style.display = "block";
(function(){
var countdown = 5;
handle = setInterval(function() {
countdown--;
if (countdown >= 0) {
span = document.getElementById("countdown");
span.innerHTML = countdown;
}
// Display 'counter' wherever you want to display it.
if (countdown === 0) {
window.location.href= 'http://www.google.com';
clearInterval(handle);
}
}, 1000);
})();
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
clearInterval(handle);
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
clearInterval(handle);
}
}
Я хочу поместить его в этот файл:
{{ attach_library('/popup_external') }}
{% set header = content.field_header_text_external %}
{% set link = content.field_external_quote_link %}
{% set phone = content.field_text_html_phone %}
{% set popup %}
HTML HERE
{% endset %}
Это для Drupal,но я не могу заставить HTML отображаться там как фактический HTML, а просто как обычный текст, даже если я использую {{popup | raw}}
Чего мне не хватает, чтобы помочь мне вставить этот JS вфайл ветки легче ??