jQuery:模板化数据

发布于 2024-07-30 10:52:24 字数 352 浏览 3 评论 0原文

我有一个独特的情况,我正在构建一个网站,该网站将通过 AJAX 调用数据并将其加载到“容器”中(基本上只是根据从 AJAX 回调检索的元素进行样式设置和排列的 div)。

我不确定当一切都完成后,将创建多少个独特的容器类型(样式化和渲染),因此我正在寻找一种解决方案,允许我将容器存储在一个单独的文件,根据需要动态加载它们,填充内容,并将它们呈现在页面上。

我不确定是否应该编写自己的加载/模板解决方案或使用现有的 JavaScript 模板引擎(例如:Pure)。

我对使用现有 JavaScript 模板解决方案犹豫不决的原因是它们似乎都专注于现有页面元素的绑定和循环,而我更关心加载和绑定到动态内容的能力。

I have a unique situation where I'm building a site that will call data via AJAX and load it into "containers" (basically just divs styled and arranged according to elements retrieved from the AJAX callback).

I'm not sure how many of these unique container types will be created (styled and rendered) when all is said and done, so I'm looking for a solution that will allow me to store containers in a separate file(s), load them dynamically as they are needed, populate the content, and rendered them on page.

I'm not sure if I should write my own loading/template solution or use an existing JavaScript template engine (e.g.: Pure).

The reason I'm hesitant to use an existing JavaScript template solution is they all seem focused on binding and looping on existing page elements, whereas I'm more concerned with the ability to load-up and binding to dynamic content.

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

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

发布评论

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

评论(4

林空鹿饮溪 2024-08-06 10:52:24

您可能想尝试一下 jQote,它是最强大的 jQuery 模板引擎,因为它允许您在模板中使用脚本。

去看看吧,我保证它会满足你的需求。

http://aefxx.com/jquery-plugins/jqote

You might want to give jQote a try, it's the most powerful jQuery templating engine as it let's you use scripting inside your templates.

Go check it out, it'll suit your needs, I promise.

http://aefxx.com/jquery-plugins/jqote

南风起 2024-08-06 10:52:24

从 JST 开始之后,我们转向了 EJS:

http://embeddedjs.com/

它更强大,语法更简单,您可以将模板放在不同的文件中。

该网站也很不错。

After starting with JST, we moved to EJS:

http://embeddedjs.com/

It's more powerful, syntactically simpler, and you can put your templates in different files.

The website is pretty nice too.

熊抱啵儿 2024-08-06 10:52:24

我计划在未来的项目中使用 jTemplates ,该项目需要做这样的事情,它非常快并且有一个不错的 jQuery 插件

I am planning to use jTemplates for a future project that will need to do something like this, it is very fast and has a nice jQuery plugin

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