# 何时(不)使用 Handlebars?

¥When (not) to use Handlebars?

本节应该让你概述 Handlebars 的优点和缺点。理想情况下,它可以让你了解 Handlebars 是否适合你的使用案例,并就选择 Handlebars 做出明智的决定。

¥This section should give you an overview over the strengths and weaknesses of Handlebars. Ideally, it enables you to see if handlebars fits your use case and make an informed decision about choosing handlebars or not.

关于在浏览器中使用 Handlebars 的注意事项

Handlebars 是一个纯粹的渲染引擎。如果你希望允许人们编写用于渲染 HTML 页面、电邮或 Markdown 文件的模板,那么它会很有效。

¥Handlebars is a pure rendering engine. It works well if you want to allow people to write templates for rendering HTML-pages, e-mails or markdown files.

它没有对事件处理、访问后端服务或增量 DOM 更新的内置支持。

¥It has no built-in support for event-handling, accessing backend-services or incremental DOM updates.

如果你想构建一个单页应用并且想要处理用户输入,你可能应该寻找像这样的框架

¥If you want to build a single-page application and you want to handle user-input, you should probably look for a framework like

# 专业 Handlebars

¥Pro Handlebars

  • Handlebars 非常适合在 CLI 应用中渲染、非 HTML 文本内容、纯内容的服务器端渲染。

    ¥Handlebars is good for rendering in CLI-apps, non-HTML text content, server-side rendering of pure contents.

  • Handlebars 已被移植到许多编程语言(Java、Rust 等)。

    ¥Handlebars has been ported to many programming languages (Java, Rust etc).

# Contra Handlebars

  • Handlebars 不适合 DOM 的快速(增量)更新、事件处理、前后端通信。

    ¥Handlebars is not good for fast (incremental) updates of the DOM, event-handling, frontend-backend communication.

Last Updated: 2024/3/9 17:51:41