ryanmorr / stache

Micro mustache-style template parser
The Unlicense
4 stars 0 forks source link

What a graet lib, thx. #12

Open dux opened 2 months ago

dux commented 2 months ago

I was looking for something like this for hours, thought I need to code it myself, uf.

I added in my fork support for Object elements, converts them to Array, do you want me to push it?

if (loop) {
  if (data[loop[1]].constructor === Object) {
    return `'); Array.from(Object.entries(${loop[1]}), ([key, value]) => [key, value]).forEach((${loop[2]}) => { _sequence.push('`
  } else {
    return `'); (${loop[1]}).forEach((${loop[2]}) => { _sequence.push('`;
  }
}
ryanmorr commented 1 month ago

You're welcome to send a PR, it may be awhile before I get to it.