0

I'm studying lms service that edx-platform. It's using the python 2.7 + django. In general, the use python template syntax is as follows:

{% 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 %}

But edx-platform is used as follows:

<%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">

I do not understand the syntax. Maybe Single line is "%" , Multiple lines is "<% %>" This is python syntax? How to use that syntax?

Karol S
  • 9,028
  • 2
  • 32
  • 45
Cingyo
  • 13
  • 2

1 Answers1

4

edx-platform is using mako template language.

Mako is a template library written in Python. It provides a familiar, non-XML syntax which compiles into Python modules for maximum performance. Mako's syntax and API borrows from the best ideas of many others, including Django templates, Cheetah, Myghty, and Genshi. Conceptually, Mako is an embedded Python (i.e. Python Server Page) language, which refines the familiar ideas of componentized layout and inheritance to produce one of the most straightforward and flexible models available, while also maintaining close ties to Python calling and scoping semantics.

See documentation for Mako at http://www.makotemplates.org/docs/

Waheed
  • 645
  • 1
  • 6
  • 9