Use of % in HTML files

Asked

Viewed 143 times

3

I noticed that some web pages use %header% and %footer% to put the header and footer among other things (I saw this in themes for Opengame Panel), I did not understand how they work and how the browser will get such a header and footer.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" />

  <title>%title%</title>
  <link rel="stylesheet" type="text/css" href= "themes/Metro/style.css" />
  <link href='themes/Metro/images/favicon.ico' rel='icon' type='image/x-icon'/>
  <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
  %header_code%
</head>
<body>
    %meta%
    %body%
</body>
</html>
  • Show a page that has this, post the code.

  • 4

    Can be the markings of a tempalte engine.

  • Yes no doubt and some template engine but n entedi how it works.

  • I posted an example.

  • 1

    Which extension is the file?

  • the extension and . html

Show 1 more comment

1 answer

4


This is used by the software on the server. The browser has no way to do this directly (at least not as you are talking about). Just look at the font of the page in the browser and you will see that it does not have this on the page, the replacement has already been done on the server before delivering to the browser.

It is even possible to use Javascript to perform this substitution, but it is not common. If you need to replace with JS have other forms, I put as a curiosity.

This is usually done as a form of macro text substitution. This Open Game Engine knows how to proceed with this.

He will surely do the Parsing (in Portuguese) of the page and will make a simple replacement of this variable by the content it has set up somewhere.

This can be done with a simple str_replace() or even with a rather elaborate function of parse.

The use of the character % serves to determine that it is a feedback variable and not a normal content. It is by this character that the engine will search to make the replacement.

I suggest inspecting the code of engine for details on the specific implementation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.