views:

42

answers:

1

I am building a website where my pages are written in MediaWiki Markup, for which I have a working parser function in Python.

Where exactly do I parse my markup: in the view's code, or in the template? My first guess would be something like:

return render_to_response( 'blog/post.html', {'post': post,
                           'content': parseMyMarkup(post.content) })

Is this the usual convention, or should I do something different?

+2  A: 

The general rule for deciding whether or not to place your code in the view or the template is this:

If your code is going to modify the data, put it into the view. If your code will only effect the display of the data, put it into the template.

I'm not very familiar with the markup formatting, but if you are going to be performing substitution (eg: **word** becomes <b>word</b>), then I'd put it into the view as it will be modifying your data.

Hope that helps!

b14ck