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 8260985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:14:43+00:00 2026-06-08T03:14:43+00:00

I have a few jinja template file in a path, I want to render

  • 0

I have a few jinja template file in a path, I want to render them and write them in a file, my problem is their output file name,

Is it possible that define a function in jinja template to return and prepare the template output file name, and call it from python code and retrieve its value?

this is my code:

#in here inputPath is jinja templates path
for root, dirs, files in os.walk(inputPath):
    for file in files:
        fPath = root[len(inputPath) + 1:]
        newPath = (fPath + "/" if fPath else '') + file
        template = env.get_template(newPath)
        oPath = os.path.join(outputPath, fPath)
        try:
            os.makedirs(oPath)
        except:
            pass
        oPath=os.path.join(oPath,file)
        with codecs.open(oPath,'w', "utf-8") as f:
            f.write(template.render(projectname=projectName, mainxmlpath=mainXamlPath))

in this code output file name is exactly jinja template file name.

  • 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-08T03:14:45+00:00Added an answer on June 8, 2026 at 3:14 am

    I’ve solved it,

    Template class has module attribute that contains all your template methods and defined variables

    for example template.module.foo() calls your foo macro in the jinja template.

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

Sidebar

Related Questions

I have few header files in /my/path/to/file folder. I know how to include these
I have few Vaadin tabs one of them is displaying an table and some
I have few values existing in data base,i need to update them but,i am
I have few custom controls (image views) added programmatically to table cell. I want
i have few variables like this: self.lamp_1 self.lamp_2 self.lamp_3 self.lamp_4 and now i want
i have few textfields in my php form. i want to handle the keypress
I have few simple django-based sites and I their number increasing all the time.
I have few fields and I want the values inside those fields to get
I have few classes that I need to annotate with a name so I
i have few texboxt and dropdownlist, which their id would be something like txtName1,

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.