pugjs/pug

`each` should recognize iteration protocol objects

Aberta

#3.170 aberto em 13 de ago. de 2019

 (10 comentários) (1 reação) (0 responsável)JavaScript (1.955 forks)batch import
Being Worked OnGood First Issue

Métricas do repositório

Stars
 (21.509 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Pug Version: 2.0.4

Node Version: 8.10.0

Input JavaScript Values

var pug = require('pug');

var map = new Map([['foo', 'bar']]);

var html = pug.renderFile('input.pug', { some_iterable: map });

console.log(html);

Input Pug

h1 Pug iteration test file
each el in some_iterable
     p= el[0]
     p= el[1]

Expected HTML

<h1>Pug iteration test file</h1><p>foo</p><p>bar</p>

Actual HTML

<h1>Pug iteration test file</h1>

Additional Comments

Here's the relevant MDN documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

I would be happy to prepare a PR implementing this change but wanted to open an issue first to make sure there aren't any issues I haven't thought of yet. I also think this will be backwards-compatible pretty easily, but don't have the time to double-check at the moment. I'll do that soon.

Guia do colaborador