Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6a13d3bb
Commit
6a13d3bb
authored
Jun 07, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documenting customtag format, and making it less brittle
parent
a83fdc71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
common/lib/xmodule/template_module.py
+27
-3
No files found.
common/lib/xmodule/template_module.py
View file @
6a13d3bb
...
...
@@ -3,12 +3,36 @@ import json
from
x_module
import
XModule
,
XModuleDescriptor
from
lxml
import
etree
class
ModuleDescriptor
(
XModuleDescriptor
):
pass
class
Module
(
XModule
):
"""
This module supports tags of the form
<customtag option="val" option2="val2">
<impl>$tagname</impl>
</customtag>
In this case, $tagname should refer to a file in data/custom_tags, which contains
a mako template that uses ${option} and ${option2} for the content.
For instance:
data/custom_tags/book::
More information given in <a href="/book/${page}">the text</a>
course.xml::
...
<customtag page="234"><impl>book</impl></customtag>
...
Renders to::
More information given in <a href="/book/234">the text</a>
"""
def
get_state
(
self
):
return
json
.
dumps
({
})
return
json
.
dumps
({})
@classmethod
def
get_xml_tags
(
c
):
...
...
@@ -20,6 +44,6 @@ class Module(XModule):
def
__init__
(
self
,
system
,
xml
,
item_id
,
state
=
None
):
XModule
.
__init__
(
self
,
system
,
xml
,
item_id
,
state
)
xmltree
=
etree
.
fromstring
(
xml
)
filename
=
xmltree
[
0
]
.
text
filename
=
xmltree
.
find
(
'impl'
)
.
text
params
=
dict
(
xmltree
.
items
())
self
.
html
=
self
.
system
.
render_template
(
filename
,
params
,
namespace
=
'custom_tags'
)
self
.
html
=
self
.
system
.
render_template
(
filename
,
params
,
namespace
=
'custom_tags'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment