调试无提示损坏的模板标签的好方法是什么?

发布于 2024-10-04 10:04:44 字数 275 浏览 0 评论 0原文

我有一个模板,它从 django.contrib.markup 库调用 markdown 模板标签。在我的本地系统上它工作正常,但在服务器上,由于某种原因, content|markdown 调用仅返回内容,而不是标记。任何日志中都没有抛出错误,并且 TEMPLATE_DEBUG = True 没有给我任何东西。我已将调用放入实际的 markdown() 函数中,但它们从未被调用。所以我最好的猜测是,由于某种原因,模板顶部的加载标记调用失败了。

有没有好的方法来模拟模板环境并找出发生了什么?调试工具?需要寻找什么?

I have a template that calls the markdown template tag from the django.contrib.markup library. On my local system it works fine, but on the server, for some reason, the content|markdown call returns just the content, not marked up. No error is thrown in any of the logs, and TEMPLATE_DEBUG = True doesn't get me anything. I've put calls in the actual markdown() function, and they never get called. So my best guess is that for some reason the load markup call at the top of the template is failing.

Are there good ways to emulate the template environment and find out what's happening? Debugging tools? Things to look for?

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

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

发布评论

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

评论(1

百合的盛世恋 2024-10-11 10:04:44

您可以在模板标记模块中放置一些内容来记录模块何时加载,这样您至少可以确认是否正在加载 Markdown 过滤器。

您还可以在同一模板文件中创建另一个名为“tester”的函数,或者简单地将“TEST”一词附加到字符串中......然后查看该模块中的任何过滤器是否正确运行。

You could put something in the template tag module that records when the module is loaded, so you could at least confirm whether or not the markdown filter is being loaded in at all.

You could also create another function in the same template file called "tester" or something that simply appends and prepends the word "TEST" to the string...then just see if any of the filters in that module are running correctly.

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