Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8269143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:07:35+00:00 2026-06-08T06:07:35+00:00

I am using python’s bottle framework to develop a simple web page. I am

  • 0

I am using python’s bottle framework to develop a simple web page. I am having trouble understanding how to pass a dictionary to a subtemplate. Example code:

mydictionary:

{
message: "Hello World",
...other template vars ... 
}

Router.py

@route('/index.html')
@view('index.tpl')
def index():
    return mydictionary

views/index.tpl

<body>
%include subpage1 ......  <-- need to pass mydictionary here
...other stuff ...
</body>

views/subpage1.tpl

<div>This is a test: {{message}}</div>

The documentation page states:

*The %include Statement: You can include other templates using the %include sub_template [kwargs] statement. The sub_template parameter
specifies the name or path of the template to be included. The rest of
the line is interpreted as a comma-separated list of key=statement
pairs similar to keyword arguments in function calls. They are passed
to the sub-template analogous to a SimpleTemplate.render() call. The
**kwargs syntax for passing a dict is allowed too*:

However, no example is given on how to pass dictionary with this **kwargs to subtemplates. Anyone ever done this? If I just say %include subpage1 mydictionary, bottle complains mydictionary is undefined (even though mydictionary is a global dict [defined in Router.py]).

regards
GA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:07:36+00:00Added an answer on June 8, 2026 at 6:07 am

    I got around this by doing the following in the template file:

    views/index.tpl

    <body>
    %from mydictfile import * <-- importing mydict here
    %include subpage1 mydict  
    ...other stuff ...
    </body>
    

    mydictfile:

    mydict = {
    message: "Hello World",
    ...other template vars ... 
    }
    

    This seems to be working for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python, I want to crawl data on a web page whose source if
I'm using Python Flask to run Python for web through FCGI with nginx. My
Using Python 2.6, Twisted 10.1, and GTK+ 2.22, with latest pygtk installed, I'm having
Using Python I want to create a property in a class, but having the
While Using Python Dictionary DataStructure (which contains key-value pair) if i want to retrieve
Using python 2.6: I have a dictionary where each key contains a list of
Using Python's csv module, is it possible to read an entire, large, csv file
Using Python how do you reduce a list of lists by an ordered subset
Using Python, I want to know whether Java is installed.
Using Python module re, how to get the equivalent of the \w (which matches

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.