I am a beginner to Python and Tornado web framework. When I was studying the template part in the book "Introduction to Tornado", one line confused me:
<link rel="stylesheet" href="{{ static_url("style.css") }}">
How can the application know where to call the function static_url
when there is no library imported to the namespace? I found static_url()
in Tornado's web module, but I can not figure out how can this function be successfully called in that template file?
The RequestHandler class has a method get_template_namespace(), documented here. If you click the source link then you'll see how it creates a dictionary where 'static_url' is set to self.static_url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With