In Tornado, you can do if statements in the HTML such as {% if true %} do stuff {% end %}. I’d like to check if the page is within an iframe.
In Javascript, it would be something like: if (top === self) { not in a frame } else { in a frame }
How can I do this in with Tornado?
Javascript has access to the browser context but a templating system will only have access to the request object.
If you control the creation of the iframe in question, for instance if that is happening on another part of your site, you might be able to pass get parameters in to the templating system or something… But in general this is something you have to do with javascript. Add javascript directly to your template or (better) include a javascript file. You can expose both the iframed and the non-iframed versions of your page in the template and have javascript select which one to show once it hits the browser.