前端标签间通信

发布于 2024-09-05 15:22:08 字数 316 浏览 8 评论 0原文

我有一个问题一直想知道。我正在为前端制作一个模板系统,其中标签被解释(如 Smarty)。我想知道让标签能够与 HTML 文档和其他“Smartyish”标签进行通信是否有价值。我希望社区能够对这种情况有一些想法。

优点:

  • 更强大(标签可以告诉其他标签如何查看)
  • 更好的结构(智能标签的行为和外观就像 html 标签)
  • 标签可以操作页面上的任何元素

缺点:

  • 标签可以操作页面上的任何元素
  • 标签可能会干扰其他元素标签
  • 代码时间会增加

I've had a question that I've been wondering for a while. I'm making a templating system for front-ends where tags are interpretted (like Smarty). I was wondering if there is value in having the tags be able to communicate with the HTML document and other "Smartyish" tags. I was hoping that the community would have some thoughts on this situation.

Benefits:

  • More power (tags can tell other tags how to look)
  • Better structure (smartyish tags behave and look just like html tags)
  • Tags can manipulate any element on the page

Drawbacks:

  • Tags can manipulate any element on the page
  • Tags can interfere with other tags
  • Code time will increase

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫七 2024-09-12 15:22:08

我认为这会使代码变得更加复杂并且更难以分析。
模板引擎的主要方法是使代码更易于理解。

添加大量编程逻辑并不是模板的目的。这些应该在 PHP 脚本中处理。

I think it would make the code much more complex and harder to analyse.
Where the main aproach of template engines is to make code easier to understand.

It is not the aim templates to add much programming logic. These should be handled in the PHP script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文