Schlipak / Yoru

夜 -- JavaScript microframework based on Template and Shadow
MIT License
2 stars 0 forks source link

How to implement a similar construction #1

Closed wku closed 7 years ago

wku commented 7 years ago

How to implement a similar construction ng-repeat - angularjs ?

Schlipak commented 7 years ago

Thanks for your interest in Yoru ! Right now most of that sort of logic can be handled through Handlebars, using the each helper like so

{{#each collection as |item|}}
  {{item}}
{{/each}}

Although currently Yoru is quite unstable, as it is just a side project I'm working on for fun.

wku commented 7 years ago

Yes excellent, thanks But how to do so ng-if angular ? if (2!=3)

Schlipak commented 7 years ago

Handlebars does not have operators, but uses helpers written in a lisp-like syntax. For your specific example you could do something like

{{#if (not-equal 2 3)}}
  ...
{{/if}}

Thought that might require writing the not-equal helper in the first place. You can do so by calling Yoru.Handlebars.registerHelper before booting the app. The Handlebars doc explains pretty well how to write helpers.

I'll reiterate again though that Yoru is unstable and not production ready. I haven't taken the time to test nor document it, but you can check out the examples directory and run the app inside for a basic demo ;)

wku commented 7 years ago

Ok thanks