Using% in html files

2

I noticed that some web pages use %header% and %footer% to put the header and the footer among other things (I saw this in themes for the OpenGame Panel), I did not understand how they work and how the browser will get it 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>
    
asked by anonymous 22.07.2015 / 23:43

1 answer

3

This is used by the software on the server. The browser can not do this directly. Just look at the page source in the browser and you will see that you do not have this on the page, the replacement has already been made on the server before delivering to the browser.

You can even use JavaScript to perform this substitution, but it is not common. If you need to replace with JS you have other ways. I put it as a curiosity.

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

It will certainly do the parsing ( in Portuguese of the page and will make a simple substitution of this variable for the content that it has configured somewhere.

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

Using the % character is to determine that it is a template variable and not a normal content. It is by this character that engine will look to make the replacement.

I suggest you inspect the engine code to see details in the specific implementation.

    
22.07.2015 / 23:47