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

  • Home
  • SEARCH
  • 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 6964495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:55:55+00:00 2026-05-27T15:55:55+00:00

The scenario would be: you have a variable called person which contains a number

  • 0

The scenario would be:

“you have a variable called person which contains a number of fields like name, address, etc which you want to pass to a partial piece of html” – this solution could be results from a search for customers for example

snippet.html

<div id="item">
  <ul>
     <li>
         <span>{{name}}</span>
         <span>{{address}}</span>
     <li>
  </ul>
</div>

mypage.html

<div id="result">
   {% include "snippet.html" passing {{person}} %}
</div>

What is the best way to achieve this. In the documentation it talks about passing context around everywhere, but that seems to me to be a rather large object when rendering templates. surely it is easier to pass specific objects into each template?

  • 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-05-27T15:55:56+00:00Added an answer on May 27, 2026 at 3:55 pm

    When you include a template into another one, it gains access to its context, so if you pass your person variable to mypage.html‘s context, you’ll be able to access it from your imported template like this:

    snippet.html:

    <div id="item">
        <ul>
            <li>
                <span>{{ person.name }}</span>
                <span>{{ person.address }}</span>
            </li>
        </ul>
    </div>
    

    mypage.html:

    <div id="result">
        {% include 'snippet.html' %}
    </div>
    

    view.py:

    def view(person_id):
        person = Person.get(person_id) # or whatever source you get your data from
        return render_template('mypage.html', person=person)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a pChart 2 bar chart which contains a variable number of
I have an architecture scenario and I would like to discuss to get your
Scenario I would like to save images with alpha transparency as .png and images
I would like to implement a producer/consumer scenario that obeys interfaces that are roughly:
Here's the scenario: I have an external swf file with x number of movieclips
I have a scenario where I want to dynamically add words of text to
I have a scenario. (Windows Forms, C#, .NET) There is a main form which
I have a deceptively simple scenario, and I want a simple solution, but it's
I have a scenario outline that has two different variables. One variable has about
I would like my Windows Phone application to access an environment variable of the

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.