variables - Pass pug mixin to JavaScript -


i have common modal on site showing endnotes. wanted create quick pug mixin don't have type structure on , over.

however, don't know how pass #id js toggle_visibility function. (note, js works perfectly, i'm trying convert mixin)

mixin modal(id, content)  div.modal(class= id)   div.modal-content= content    a.close(onclick="toggle_visibility('= id');") close  

here's example of pug code working (outside mixin)

div.modal#downloads-citations       div.modal-content         p content here show article citations         a.close(onclick="toggle_visibility('downloads-citations');") close 

what you're looking called 'attribute interpolation', , not directly supported anymore in current versions of pug (see this page in docs).

fortunately, however, there easy workaround, based on concatenation of strings. replace last line of code snippet statement:

a.close(onclick="toggle_visibility('" + id + "');") close 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -