django haystack突出显示模板标签问题
有没有办法让 django-haystack 的 {%highlight %}
模板标签显示传入的完整变量,而不是删除第一个匹配之前的所有内容?
我这样使用它:
{% highlight thread.title with request.GET.q %}
Is there a way to make django-haystack's {% highlight %}
template tag show the full variable passed in, rather than removing everything before the first match?
I'm using it like this:
{% highlight thread.title with request.GET.q %}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从未使用过 haystack,但快速浏览了 文档 和 来源 它看起来像你可以制作您自己的自定义荧光笔并告诉 haystack 使用它
,然后
在您的 settings.py 中设置
i've never used haystack, but from a quick look in the docs and the source it looks like you can make your own custom highlighter and tell haystack to use that instead
and then set
in your settings.py
@second 的答案是有效的,但是如果您也不希望它切断字符串的末尾并且您的长度低于最大长度,则可以尝试此操作。仍在测试它,但它似乎有效:
The answer by @second works, however if you also don't want it to cut off the end of the string and you're under the max length you can try this. Still testing it but it seems to work: