PHP言語のようにPythonとhtmlタグを書くことができることを、Python言語で書くことができますか(またはそのようなWebフレームワークが存在する可能性があります)。
そのような python ファイル構造を持つことができますか:
some_python_file.py:
<html>
<head>
<title>Lol</title>
<head>
<body>
My PyWeb Slang
</body>
</html>
<!-- this part should be python -->
<?py
from Eternity import Kiss
love = Kiss.Forever()
print "%s" % love
?>
申し訳ありませんが、大文字で書いています:
各行 {% goodies %} または <%= goodies %> でテンプレートが使用されていることがわかります。
{% extends "layout.html" %}
{% block body %}
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock %}
しかしPHPでは:
<div>Good Morning, Sun!</div>
<?php
echo "Happy!";
echo "Hi, WaterLand!";
?>
Python がそのようにできるとしたら、次のようになります。
<div>Good Morning, Sun!</div>
<?py
print "%s" % "Happy!"
print "%s" % "Hi, WaterLand!";
?>
アイデアはわかりましたか、それとももっと明確にする必要がありますか?
ありがとうございました。:)
うーん、もしそうなら:
mod_python で次のように記述できますか (以下の[morphyn]の例を拡張):
<html>
<%
greet = 'Hello Wee!'
answer = 'Hello Bee!'
%>
<h1><%= greet %></h1>
<h2><%= answer %></h2>
</html>
<% ... %> に 2'u 以上の行が表示されます。