PublicDesignWorkshop / FoodParent

FruitParent is the web version of application for tracking status of fruits for picking up on right time.
0 stars 1 forks source link

handlebars templates #15

Open durkie opened 8 years ago

durkie commented 8 years ago

there's lots of templates in the app that are awkward to work with because they're html embedded in javascript. have you ever tried handlebars? they're very nice because you can store your templates in a separate, non-javascript file, and you can add conditionals to them.

so this way you don't have to create a guest map template, and then re-create 99% that entire template but with 5 lines changed for an admin user, and then recreate that same template for a manager, etc. you can just do

<div>
  {{#if isAdmin}}
    <div id="admin-settings">...</div>
  {{elseif isManager}}
    <div id="manager-settings">...</div>
  {{else}}
    <div id="guest-settings">...</div>
  {{/end}}
</div>

it's much cleaner, much easier to maintain, and much less work.

ThePlushEater commented 8 years ago

I agree the templates are bit messy and not structured. So I am currently moving templates into React to make it more structured. And I will definitely look up handlebars. It looks really clean.