wycats / handlebars-site

56 stars 66 forks source link

External modules #212

Closed elmasbestia closed 5 years ago

elmasbestia commented 5 years ago

Hi, guys!

I really want to use handlebars but I have too many philosophical questions and so little time!

Perhaps you may guide me or dismiss my line of thought:

I want to use JS Objects like one that manages a hierarquical set of combos (One for State, the next one for County).

As I understand: I might use my regular HTML and include handlebars as a script and then manage my data from inside my page.

But I don't want to do so, but manage my data from Node JS and then render the complex page (With my libraries)

Is that a valid approach?

nknapp commented 5 years ago

I thought I had already written an answer to that, but I see it's not here...

If you are building in interactive application that re-renders a part of the page (i.e. the county-combo) based on an input in another combo, I would suggest you use a full-flegded SPA framework like Vue, React, Ember or Angular. That would be client-side code than.

All that Handlebars really does is: Take a JavaScript-object (or JSON) as input, apply the template and output a text (HTML, markdown, Flat ODF etc). The result, of course, depends on the template. It has no functionality for reacting to user input, re-rendering parts of the page, transfering data-objects from server to client. All that, you have to do yourself.

Personally, I would only suggest to use Handlebars in one of the following cases:

nknapp commented 5 years ago

Including Handlebars in a script-tag is not the recommende approach for production environments. Use precompilation of a packager like WebPack, Browserify or Parcel.

elmasbestia commented 5 years ago

Thank you very much

elmasbestia commented 5 years ago

Thank you very much