This is a concept that you have to get a firm grasp of.

There is a file "layout.html" that contains all of the base HTML that you 
might want on every page in your site. It has a templating instruction 
{{include}} which is where each of your individual view files will get 
inserted.

If you recall the default "index.html" file, you should have seen at the top 
"{{extend 'layout.html'}}". This is what tells web2py to take your 
index.html file and insert it into the layout.html file.

What you also should have seen is in controllers/default.py:

def index():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html
    """
    return dict(message=T('Hello World'))

When you visit "/welcome/default/index" in your browser, it looks for the 
app "welcome, then "default.py" in your controllers file and then "def 
index()" in default.py. You will see that index() returns a variable 
"message='Hello World'". "message" is sent to the view file 
views/default/index.html and is available like this: {{=message}}. The 
default index.html file includes some other content but you should be able 
to find {{=message}} in there somewhere. Try editing "message" to 'Good bye 
world'. Or try moving {{=message}} to a different position in index.html and 
see what happens.

Reply via email to