-
Notifications
You must be signed in to change notification settings - Fork 32
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
Benchmarks #1
Comments
@james2doyle yes that would be interesting. I'm 100% sure it will be beaten if compilation time is taken into account, but assuming it isn't then the compiled JS should be pretty competitive. |
You never know though. Maybe htmling beats one of them on large objects. Or maybe it handles nesting better. Something to consider. |
others to consider: Jade and Handlebars |
Yeah thats true. But I left them out because there is a lot of logic in those templates, typically |
@james2doyle HTMLing supports just as much logic as those, I probably need to add some more examples, but essentially all of polymer's template syntax is supported, so you can do this: <div>
<template if="{{a > b && day === 'Monday'}}">
<p>It's a Monday, and {{a}} is bigger than {{b}}!</p>
</template>
<template bind="{{users[0] as firstUser}}">
<p>{{firstUser.name}}'s name as an MD5 is {{firstUser.name | md5}}.</p>
</template>
<content>This is some fallback content which will be rendered unless some other content is specified</content>
</div> and then after compilation you could do this: template.md5 = require('some-md5-lib');
console.log(template.render({
a: 1,
b: 0,
day: 'Monday',
users: [
{name: 'James'}, {name: 'Charles'}
]
}, "Some Content"); which would give you: <div>
<p>It's a Monday, and 1 is bigger than 0!</p>
<p>James's name as an MD5 is d52e32f3a96a64786814ae9b5279fbe5.</p>
Some Content
</div> |
Oh sweet ok. Thats awesome! |
I came in to open a new issue with just that in mind. I can do if constructs in node using htmling right? Perfect.. thanks! |
@rvinay88 yes 😄 the full syntax is supported |
I'm going to make a new repo with a full benchmark suite to compare different implementations, from my initial investigations HTMLing is pretty competitive:
Handlebars is better at simple partials than us, I think it's because they can get away with doing a simple key lookup in an object when finding the correct partial, whereas we must resolve the partial's path and this is showing up in these naive benchmarks. There'll be a way to cache that I think. |
@james2doyle @rvinay88 I added HTMLing to an existing set of benchmarks here, it performs pretty well:
|
Definitely a reason to pick this over handlebars! Thanks a lot for the update. |
Hey there,
this looks like a cool project. I was wondering if there was a plan to compare this to some other template libraries?
Some of the top of my head would mustache and dust. Although dust might be a little heavier in that it has if/else and block/partials.
The text was updated successfully, but these errors were encountered: