Reputation: 53
Trying to use {{ post|truncatewords:"100" }} for a teaser in Cactus. The post is using the markdown filter and truncate words is showing the html. I also tried {{ post|truncatewords:"100"|markdown }} which does seem like it is attempting to format correctly, however line breaks and body tags still show.
Example Output:
{'body': u'\n\n
Cactus templates are set up using the Django Template Language. Django\u2019s template language is both powerful and easy to use. A template is simply a HTML file. Let\'s take a look at how to use the blog template.
\n\n General file str...
Seems like this should be pretty straight forward but I cannot figure out what I am doing wrong.
Any help would be greatly appreciated.
Thanks.
Upvotes: 1
Views: 285
Reputation: 1840
Looks like post
is a dictionary, and the post body you want to show is under the body
key. You probably want something like:
{{ post.body|markdown|truncatewords_html:100 }}
Upvotes: 1