gpt4 book ai didi

html - 让 flymake 与 Django 一起工作?

转载 作者:太空宇宙 更新时间:2023-11-04 13:25:04 24 4
gpt4 key购买 nike

在使用 Django 模板时如何禁用 flymake?

Flymake 非常适合编辑 python 文件,但确实给我带来了 django 模板的问题。例如,以下模板不会抛出任何错误,但语法高亮显示不适用于模板标签:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>{% block title %}Page title{% endblock %}</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>

<body>
{% block content %}
<p>… Your HTML content here …</p>
{% endblock %}
</body>
</html>

但是,以下模板充满了 flymake 错误的字体锁定:

{% extends base.html %}

{% block content %}
<h1>Welcome!</h1>
{% endblock %}

将鼠标悬停在错误上会显示 flymake 正在提示“Text not allowed”。

我已按照 this related question 中的每个解决方案进行操作,但它们都没有为 html 缓冲区禁用 flymake。我什至尝试重命名我所有的模板文件以 .djhtml 而不是 .html 结尾,但在重新访问文件后 flymake 仍然处于事件状态。我确实更改了自动模式列表以将 django-html-mode 应用于 .djhtml 文件,所以问题可能就在那里。

更新:我发现切换到 html-mode 不会出现这个问题,因为我已经实现了前面提到的解决方案。但是,如果我切换到 nxml-modedjango-html-mode(我想使用的),flymake 会再次启动并告诉我它是:

Using schema /usr/local/Cellar/emacs/HEAD/share/emacs/24.0.93/etc/schema/xhtml.rnc

Snow Leopard 上的 Emacs24 Carbon。

GNU Emacs 24.0.93.1 (i386-apple-darwin10.8.0, NS apple-appkit-1038.36) of 2012-02-21 on hook

最佳答案

django wiki列出了使用 emacs 的几个选项,但没有提供关于每种模式的特定优势和劣势的大量指导。

我目前使用的解决方法是使用 django-html-mumamo-mode 而不是 django-mode。这是我在使用 django 设置 emacs 的过程中得出的结论。

请记住,随着这些软件包的开发,其中一些观察结果可能会发生变化。

小马模式

Looks promising ,但文档不完整,模板中的语法突出显示对我不起作用。这是我真正想要的,但其他人可能会喜欢内置的其他功能。

django-html-mumamo-模式

这与 nXhtml 捆绑在一起.没有包含任何片段,但可以通过 Google 或 imported from a Textmate bundle 找到片段。与 yasnippet。说起来,这个模式conflicts with the yasnippet-bundle通过 ELPA 提供,因此请务必遵循开发主干以避免必须 restart emacs everytime you trigger a snippet .顺便说一句,语法突出显示很棒,您可能会喜欢作为 nXhtml 一部分的通用 Web 开发功能。

django 模式

语法高亮和跳转到标签,包括一些片段;然而,django-mode doesn't play nice with flymake ,我认为这是因为它源自 nxml-modedjango-mode 不再在开发中,nxml-mode 也不是我能收集到的。 django-html-mumamo-mode 不会遇到这个 flymake 问题,因为 nXhtml 包含对开箱即用的 flymake 的非常好的支持。

关于html - 让 flymake 与 Django 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9390495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com