Going through docs for learning purposes, I can't find much information how to solve my issue, basically we can provide a dict mapping of UI modules to an Application instance like so:

from tornado.web import Application
from .features.components import Button

modules = {
    "ui_modules" : [

def create_app():

    return Application([
        url(r"/", MainHandler)
    ], template_path = os.path.join(os.path.dirname(__file__), "templates"),
        compiled_template_cache = False,
        ** modules)

We can also provide a singleton:

modules = {
    "ui_modules" : Button

But, I am looking for nested modules, something similar to this:

modules = {
    "ui_modules" : {
        "components" : {
            "button" : Button,
            "select" : Select,
            "form" : Form

Ultimately, to be able to reference my module from the parent template file(main.html) as so(similar but not quite there yet):

{% module components["button"](text, color = "red") %}

Is there any possibility of doing so, because Tornado actually doesn't like this kind of input as he can't recognise nested properties/modules?

0 Answers