Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap out Mustache rendering engines #62

Open
sizzlemctwizzle opened this issue Dec 7, 2013 · 5 comments
Open

Swap out Mustache rendering engines #62

sizzlemctwizzle opened this issue Dec 7, 2013 · 5 comments
Labels
enhancement Something we do have implemented already but needs improvement upon to the best of knowledge.

Comments

@sizzlemctwizzle
Copy link
Member

I wrote my own Mustache template rendering engine for Node.js awhile back. It is much faster and more memory efficient than Mu. Instead of building a parse tree in memory and then evaluating it to render (waking the parse tree and figuring out context.. ew), my engine transforms a template into a node module and then requires it. To render, it just passes the options to the module. The code is much simpler (so easier to optimize) and because it's a module, V8 can actually preform optimizations on the rendering code. I still need to implement Mustache partial syntax before it becomes a drop-in replacement for us. Template rendering speed and efficiency is important for us because we do it for essentially every request, and templates are just going to get more large and complex going forward.

@jerone
Copy link
Contributor

jerone commented Dec 7, 2013

Without looking detailed at it, my concern is stability and documentation. Mustache has been around a bit longer and tested throughout. Also examples and documentation can be found on the Internet.

When (not if) openuserjs becomes popular performance will be a big issue, so if you think this will help...

@sizzlemctwizzle
Copy link
Member Author

my concern is stability and documentation.

I wouldn't say that Mu has stellar documentation. It's pretty sparse. As far as stability is concerned, my implementation is much simpler and therefore easier to debug. I still need to fill it with comments. It was just an experiment on a theory I had of building a faster rendering engine.

Also examples and documentation can be found on the Internet.

Mustache documentation can be found on the internet. We're talking about the rendering engine. There are already two implementations written in JavaScript: Mustache and Mu. The first is written in pure JS and can run in the browser. The second is written for Node.js. I wrote a third, also for node.

Mustache has been around a bit longer

Mu has been around for three years, but most of its commits are in the last year.

tested throughout

I'll give them that.

so if you think this will help...

I do, but I agree that it needs more testing if we decide to use it.

@eneko89
Copy link

eneko89 commented Dec 30, 2013

Don't know if it helps, but there are a lot of Mustache implementations in javascript, not just Mustache.js and Mu.

And they are probably more out there. Be aware that some of them are not being actively supported/developed. Mustache.js and Handlebars are the most active projects (the last one specially). Think it twice before reinventing the wheel.

@sizzlemctwizzle
Copy link
Member Author

not just Mustache.js and Mu.

I know. I looked into them before rolling out my own version. I took a different approach than any of the others in my implementation. A template transformed into pure js will always be faster than evaluation. Apparently Mote does something similar but the advantage of keeping it in-house and not having to rely on someone else outweighs any benefits of using it imo.

Think it twice before reinventing the wheel.

I already did, so this advice is too late. I just need to finish it off by implementing support for partials.

@Martii Martii mentioned this issue Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something we do have implemented already but needs improvement upon to the best of knowledge.
Development

No branches or pull requests

4 participants