react-engine vs other template engines

后端 未结 1 2112
闹比i
闹比i 2021-01-02 08:46

I was wondering to use paypal\'s React Engine (https://github.com/paypal/react-engine), but I have some doubts:

What are the benefits over other template engines lik

1条回答
  •  抹茶落季
    2021-01-02 09:07

    The main difference between react-engine and template engines is only when the browser enables the user to interact with the browser page. Nevertheless, it is important how machines have access to individual data.

    Assuming we want to run a simple webpage. Just a scrolling and open text information. Using template engines, like Handlebars.js, typically, when the browser request hits to the server, it tries to figure it out how to respond and what to do. That said, the template engine may reference existing fetched data from files stored into a local and accessible source. Those are loading all the defined data regarding the site template file (i.e. head, meta, title, etc.), with a render of incomplete HTML string. This HTML is then sent back to the Browser and rendered.

    The react-engine, on the same side it happens the use of the same rendering mechanism. However, instead of a template engine semantic, it uses JSX, or if we want, we can also use JavaScript. The JSX is, therefore, broader then template engines. A great article by Hajime Yamasaki Vukelic complies the separation of concerns from a different angle between JSX and HTML templates.

    With template engines, you feed the library a string (usually but not necessarily HTML), which is then converted into a piece of JavaScript code which generates virtual DOM structures when executed. At design time, templates are just strings, so we don’t have direct access to the surrounding code. For instance, we can’t import helper functions, or call methods. These things are only possible through abstractions called directives (and possibly other names depending on where you are coming from). Directives are the glue between the HTML and the JavaScript.

    So far so good, there is no relevant difference between both solutions. Links to next or previous simple webpage are just simple

0 讨论(0)
提交回复
热议问题