Ask Your Question

cannot add templatetags

asked 2011-08-10 07:56:17 -0500

Samuel's avatar

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-08-10 08:12:54 -0500

Evgeny's avatar

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?

edit flag offensive delete link more


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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-08-10 07:56:17 -0500

Seen: 1,178 times

Last updated: Aug 10 '11