-
Notifications
You must be signed in to change notification settings - Fork 26
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
idea/question: Handlebars as alternative to JSX? #26
Comments
Hi Jeff -- Thinking aloud, if there were a translator that took the AST used by one of the existing handlebars parsers, like incremental-bars or htmlbars, and converted it into the AST used by the surplus compiler, then it could re-use the surplus backend (transforms and codegen). |
On a similar token have you considered ES6 template literals? I guess you lose the ability to package functions as components which is huge, but on the tradeoff no special syntax and uses pure ES6 javascript. No helpers or context required either. I guess because it's precompiled the template literals don't actually help much. And JSX having an established syntax for binding wins out. |
Yeah, I have looked at template literals as an alternate syntax. Avoiding the need for a build step would be a definite plus. The challenge is that in order for automatic dependencies to work, you might need to wrap some of the expressions in lambdas, something that is done for you automatically by the current surplus compiler. So for instance, the equivalent to the JSX expression:
might be something like
Note the It probably wouldn't be quite as fast as surplus, as some optimizations wouldn't be possible and others might take too much runtime, but no compile phase would be nice. |
@Jeff17Robbins I built Hyperstache for just this use case, works with most tagged template solutions out of the box. https://github.com/luwes/hyperstache |
Mind you Surplus is not one of those Tagged Template solutions. So I think @luwes was trying to say is if you are interested in a library similar to Surplus where you can use handlebars he has created the library Sinuous. This is a good option but has the tradeoffs that @adamhaile highlighted. |
Hi. Your project looks really great. The S package is super performant -- congrats!
We're somewhat stuck on the Handlebars approach to templating, and were wondering if your architecture support Handlebars instead of/in addition to JSX for the templates?
For example, incremental-bars implements Handlebars but uses incremental-dom as its backend, instead of strings.
But I like your approach of going straight to the DOM. It feels similar to Ractive , which has the Handlebars goodness, but, alas, not the speed of
S
.I guess one possibility would be for Ractive to leverage S in place of its current data/computed model? But another possibility would be for Surplus to offer Handlebars support.
Of course, we could just learn JSX instead... :-)
The text was updated successfully, but these errors were encountered: