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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:54:02+00:00 2026-06-09T15:54:02+00:00

I have hmtl template, and want to add some values there. I was going

  • 0

I have hmtl template, and want to add some values there.
I was going to use sting.format module with such rule:

"Hello {name}! I am {years} years old".format(name = "Bob", years = "25").

So I have written such test

x = open(source_folder + "template.html", 'r')
  template = x.read()
  template.format(tester = "John")
  studio_html = open(studio_folder + "/" + studio_name + ".html", 'w')
  studio_html.write(template)

The beginning of the file is:

  {tester}
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1  /DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta ....

The full version of the file is here – http://bit.ly/R4zxQ6

I run the script, and it gives me errors, which tell that the html file contains other “{ }” containers… what can you suggest to do to avoid this problem?

Best regards, Sasha.

  • 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-09T15:54:03+00:00Added an answer on June 9, 2026 at 3:54 pm

    As has already been suggested, a real templating module would give you the best flexibility. However, it is possible to do it how you originally intended. To do so, you can escape the curly braces that should not be used for string formatting. For example, you would want to modify this:

    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    

    as this:

    function MM_swapImgRestore() {{ //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }}
    

    When doubled/escaped like this, the format/vformat method will ignore them while parsing. Replacement fields should still have only one set of braces, e.g. {tester}.

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

Sidebar

Related Questions

OK so I have a php include that houses some queries and want to
I have a html template that I want to retrieve from the resources file
I have a bunch of hmtl buttons, some have a value like: Title* I
I have some data that I need to associate with specific element such as
We have a variable with hmtl code inside. <?php echo $list; ?> This will
the procedure: i have a script which uploads images (via hmtl-form and php) for
I have a string: string hmtl = "<DIV><B> xpto </B></DIV> and need to remove
Have a photography site that I want to prevent image copying from. How can
I have a MonoTouch application that generates some PDFs locally and then prints them
I have an HMTL / CSS website built in Dreamweaver CS4 and I would

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.