First time here? Check out the FAQ!

cannot add templatetags

I have created a new template "mytemplate.html" extending "two_column_body.html". It was working until I try to use custom tags. I have created the file askbot/templatetags/ containing for instance :

def mytag():

In "mytemplate.html" I add :

{% load mytags %}
 <label>{% mytag %}</label>

and I get this messages in the logs :

/usr/local/virtualenv/askbot/lib/python2.6/site-packages/askbot/middleware/ TIME: 2011-08-10 14:31:34,457 MSG: <class 'jinja2.exceptions.TemplateSyntaxError'>
/usr/local/virtualenv/askbot/lib/python2.6/site-packages/askbot/middleware/ TIME: 2011-08-10 14:31:34,457 MSG: Encountered unknown tag 'mytag'. Jinja was looking for the following tags: 'endblock'. The innermost block that needs to be closed is 'block'.

Any idea?

Samuel's avatar
asked 2011-08-10 07:56:17 -0500
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

1 Answer


In Jinja2 template tags are harder to add, but almost in all cases they can be replaced with a macro.

There are lots of macros in file askbot/skins/default/templates/macros.html and examples of use are in many places, for example in a template question.html.

Do you need to add extra context variables, right now you can add them via a custom template context processor, we can also add extra_context parameters to the views. Could you explain in more detail what you are trying to do?

Evgeny's avatar
answered 2011-08-10 08:12:54 -0500
edit flag offensive 0 remove flag delete link


well.... I have forked and highly refactored the project Speeqe in order to be able to plug it to askbot. At this stage my askbot instance is able to list chatrooms in a jabber server and has a web chat client embedded. It is a light beta version of chat.stackoverflow. Now I have added a new tab (chat) in the main-nav to list the chatrooms. Imagine that my template in my initial question lists the chatrooms. The tags used managed the connection to the xmpp server. Let me know if you are interested.
Samuel's avatar Samuel (2011-08-10 08:59:44 -0500) edit
Samuel's avatar Samuel (2011-08-10 11:16:14 -0500) edit
add a comment see more comments