-
Hi, I'd need a mustache or even better handlebars parser with PEGTL, but I can't seem to get anything usable done. Maybe someone could add such examples here? That would be so awesome! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Reasonably useful "examples" would need more than just parsing of a mustache or handlebar template, you'd also need to apply data. That data is, if I read it correctly, delivered in YAML, which is way beyond the scope of the PEGTL. It might be a better fit for our JSON library, which also uses the PEGTL. We could start by adding a small mustache example there which only accepts JSON (or JAXN, our enhanced version of JSON) instead of YAML. The rest seems fairly simple, but as usual the devil might be in the details. We were also discussing adding a YAML parser to our JSON library, but that is quite some work and the YAML spec is, well, not the easiest spec. @ColinH, what do you think? |
Beta Was this translation helpful? Give feedback.
-
My first question @patlecat, what exactly do you need, just the grammar, a parser that stores the mustache rules, or a full mustache processor? And how far did you get? Just the grammar could be added to the PEGTL contrib without too much effort, a full processor would indeed have to be part of (or based on) our JSON library... |
Beta Was this translation helpful? Give feedback.
-
Well in the end I need to process the data too to replace it in HTML with dynamic values. If I could, as a n00b, get to understand how to parse it and how i can then add processing functions that would be great. Naturally I would mostly prefer just a ready processor instead. I feel it's a bit too much without a mentor to dig into parsing alone. |
Beta Was this translation helpful? Give feedback.
-
A complete mustache processor is out of scope of this library, and too much work for a casual evening project. We will keep it in mind and might add it to our json library in the future, however there are many other things on our todo list that need to be done first to lay the groundwork. Should you start on a mustache processor yourself you are of course highly welcome to ask any further question that might arise, in particular regarding the PEGTL. Happy hacking! |
Beta Was this translation helpful? Give feedback.
-
Thanks, I hope I can find the courage to do it. Mustache is really the most used template syntax and like the lowest common denominator. So I hope you see how popular it is. It would be worth adding it. |
Beta Was this translation helpful? Give feedback.
A complete mustache processor is out of scope of this library, and too much work for a casual evening project. We will keep it in mind and might add it to our json library in the future, however there are many other things on our todo list that need to be done first to lay the groundwork. Should you start on a mustache processor yourself you are of course highly welcome to ask any further question that might arise, in particular regarding the PEGTL. Happy hacking!