来自官方jinja网站的示例代码:
{% if not standalone %}{% extends 'master.html' %}{% endif -%}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>{% block title %}The Page Title{% endblock %}</title>
<link rel="stylesheet" href="style.css" type="text/css">
{% block body %}
<p>This is the page body.</p>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
据我了解,当standalone为true时,将打印以下代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>{% block title %}The Page Title{% endblock %}</title>
<link rel="stylesheet" href="style.css" type="text/css">
{% block body %}
<p>This is the page body.</p>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
当standalone为false时,会打印出来:
{% if not standalone %} …Run Code Online (Sandbox Code Playgroud) 因为 'code' 是下面 MethodView 类 C 的 get 方法的参数,所以当我调用 url_for('c', code='O7A') 时,我希望得到的 url 是:/c/O7A
我看到的不是预期值,而是:/c/?code=O7A
from flask import Flask, url_for
from flask.views import MethodView
app = Flask(__name__)
class B(MethodView):
def get(self):
return 'ok'
def post(self):
print url_for('c', code='O7A')
return 'ok'
app.add_url_rule('/b',
view_func=B.as_view('b'),
methods=['GET', 'POST'])
class C(MethodView):
def get(self, code):
return 'ok'
def post(self):
return 'ok'
app.add_url_rule('/c/<code>',
view_func=C.as_view('c'),
methods=['GET'])
app.add_url_rule('/c/',
view_func=C.as_view('c'),
methods=['POST'])
print app.url_map
if __name__ == "__main__":
app.run()
Run Code Online (Sandbox Code Playgroud) 我尝试修改ng-checked示例,以便单击其中一个复选框会自动更新另一个.
单击A,然后单击B,然后单击A,则不会执行我期望的操作.
我应该查看哪些文档来了解发生了什么?