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

Making Handlebars work: Should riot-tmpl ignore {{expr}} but not {expr}? #22

Closed
chardskarth opened this issue Nov 9, 2017 · 3 comments
Labels

Comments

@chardskarth
Copy link

I am looking at riot-tmpl and was wondering if we could recode it to ignore the double braces. Would it be hard to implement this? Or what can you guys say about this work around to make handlebars work?

In my setup, I would have to do two rendering stages:

Handelbars.compile(riot.render())(context)

Can someone please validate this suggestion, thanks!

@chardskarth
Copy link
Author

chardskarth commented Nov 11, 2017

@GianlucaGuarini @aMarCruz Greetings!

Would it matter if the implementation of this riot-tmpl be improved? In the brackets.split function, instead of using some looped RegExp, could we use a parser instead like acorn?

The benefits that I could think of right now would be:

  • Better solution for the problem. String parsing vs RegExp.
  • Theoretically, we should now be able to handle REAL 100% Javascript expression within { }. ie:
{ (function dunnoWhyWhouldAnyoneDoThis(){return "but atleast its 100% :)"})( ) }
  • I think it shouldn't consider {{$ 'handlebar_helper'}} as a template and skip it.
  • A more maintainable codebase.

I'm new to this open source community and contribution but I'd be very much willing to learn, receive constructive criticism. Riot.js is awesome the philosophy it is built under.

I'll be starting to implement this. Please let me know your thoughts. Cheers!

@GianlucaGuarini
Copy link
Member

@aMarCruz was working on the new compiler here https://github.com/aMarCruz/new-riot-compiler so at moment I don't accept pull requests changing the core of the current one. Honestly mixing handlebar templates with riot templates sounds to me a really bad idea anyway independently from the parser. I will work soon on the current parser to implement the sourcemaps asap. Thanks for your question and good luck

@chardskarth
Copy link
Author

chardskarth commented Nov 12, 2017

Oh I see, but it seems he's moving it to a TypeScript codebase. Isn't TypeScript out of riotjs' philosophy of being minimalistic? (Type noise)

I'm using a custom build and I need my components' html to read from some global config before being compiled as a riot component. I suppose I could use mixins or even change the custom riot template braces. But I'd rather this custom build's power to do it

Goodluck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants