我正在研究 edx 平台的 lms 服务。它使用python 2.7 + django。一般来说,使用python模板的语法如下:
{% extends "base_generic.html" %}
{% block title %}{{ section.title }}{% endblock %}
{% block content %}
<h1>{{ section.title }}</h1>
{% for story in story_list %}
<h2>
<a href="{{ story.get_absolute_url }}">
{{ story.headline|upper }}
</a>
</h2>
<p>{{ story.tease|truncatewords:"100" }}</p>
{% endfor %}
{% endblock %}
但 edx-platform 使用如下:
<%namespace name='static' file='static_content.html'/>
<%!
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section
%>
<%page args="course" />
<article id="${course.id.to_deprecated_string()}" class="course">
%if course.is_newish:
<span class="status">${_("New")}</span>
%endif
<a href="${reverse('about_course', args=[course.id.to_deprecated_string()])}">
<div class="inner-wrapper">
我不明白语法。也许单行是 "%" ,多行是 "<% %>" 这是 python 语法?如何使用该语法?