Can I somehow use client-side javascript variables in pug file, for loop in objects or in arrays? Like I have some array in client-side js file: var someArray, and I wont too send this array in pug file for loop into it... is it possible?
            Asked
            
        
        
            Active
            
        
            Viewed 812 times
        
    1 Answers
0
            
            
        If you are running pug client side (as per the browser support section of the homepage), then you just pass the value into the compiled template.
var locals = {
    someName: someArray
}
var fn = pug.compile('string of pug', options);
var html = fn(locals);
If you are running pug server side, then you will have to make multiple requests to the server as described in What is the difference between client-side and server-side programming?.
 
     
    