52 lines
1.8 KiB
Plaintext
52 lines
1.8 KiB
Plaintext
<!DOCTYPE html>
|
|
<!-- This is an example file for PyHP (Python Hypertext Preprocessor).
|
|
PyHP is intended to work similarly to PHP replacing the at times quirky
|
|
PHP language with Python while still allowing for embedding in
|
|
hypertext documents.
|
|
-->
|
|
<?py
|
|
# Start of a python code block:
|
|
# The block starts after the first line break after "<?py".
|
|
# The indent of the first line of the block is assumed to be equivalent
|
|
# to 0 (unless specified otherwise) in a normal python file to allow for
|
|
# nice indented code blocks without messing up the Python syntax.
|
|
# An example of specifying the indent is provided below.
|
|
|
|
title = "PyHP - Python Hypertext Preprocessor"
|
|
text1 = "An attempt at replacing PHP with Python. "
|
|
text2 = "This is an example file that roughly describes the format."
|
|
?>
|
|
<!-- End of python block:
|
|
The block ends at the last line break before "?>".
|
|
Unless specified otherwise, the python indent of the text after a
|
|
python block is assumed to be 0.
|
|
An example of specifying the indent is provided below.
|
|
-->
|
|
<html>
|
|
<head>
|
|
<!-- insert variables just like in PHP -->
|
|
<title> <?= title ?> </title>
|
|
</head>
|
|
<body>
|
|
<h1> <?= title ?> </h1>
|
|
<p> <?= text1, text2 ?> </p>
|
|
|
|
<!-- Here is an example of an automatically populated table: -->
|
|
<table>
|
|
<?py
|
|
hello_world = "Hello World!"
|
|
for i in range(0,len(hello_world)+1):
|
|
4 ?>
|
|
<!-- python indent for the following hypertext is 4 spaces -->
|
|
<tr>
|
|
<td> <?= i ?> </td>
|
|
<td> <?= hello_world ?> </td>
|
|
</tr>
|
|
<?py 4
|
|
# start the python block with an indent of 4 spaces
|
|
hello_world = hello_world[:-1]
|
|
?>
|
|
</table>
|
|
</body>
|
|
</html>
|