strukturart / bHacker-store-client

KaiOS
MIT License
38 stars 6 forks source link

Use mustache for templating? #43

Closed farooqkz closed 4 years ago

farooqkz commented 4 years ago

At the cost of adding a dependency, the code will be shorter and more readable. https://mustache.github.io/

Simon-Laux commented 4 years ago

@strukturart is currently in the process of migrating to vuejs

strukturart commented 4 years ago

@farooqkz mustache looks interesting, do you have experience with it? because I've been trying to use vue.js for a while but just doesn't work with kaios

farooqkz commented 4 years ago

Yes from the time which I realized such a thing exist, I used it in almost every web application(Python + CherryPy, backend)! It's not hard to learn(at least the Python module was not)

strukturart commented 4 years ago

i don't know how to create the array in the right form https://github.com/strukturart/bHacker-store-client/blob/bd68293b51dc347d31ea618052018ce7e630700f/application/app.js#L154

to loop across the array https://github.com/strukturart/bHacker-store-client/blob/3b718f7ce5b1770d6f290eb25874c405ea640ca9/application/app.js#L210

farooqkz commented 4 years ago

If your template is this:

{{#data}}
{{name}} is {{age}} years old.
{{/data}}

You should have data like this:

var some_array = [{name: "Far", age: 8}, {name: "perry", age: -1}];
var rendered = Mustache.render(template, {"data": some_array});

And you'll have:

Far is 8 years old.perry is -1 years old.
Simon-Laux commented 4 years ago

If you don't want to use vue.js please reconsider react/preact. @strukturart