Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
bf62c4b7
Commit
bf62c4b7
authored
10 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Extract a pure-XBlock version of MakoModuleDescriptor
parent
b50876fc
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/lib/xmodule/xmodule/mako_module.py
+27
-8
27 additions, 8 deletions
common/lib/xmodule/xmodule/mako_module.py
with
27 additions
and
8 deletions
common/lib/xmodule/xmodule/mako_module.py
+
27
−
8
View file @
bf62c4b7
from
.x_module
import
XModuleDescriptor
,
DescriptorSystem
"""
Code to handle mako templating for XModules and XBlocks.
"""
from
xblock.fragment
import
Fragment
from
.x_module
import
XModuleDescriptor
,
DescriptorSystem
,
shim_xmodule_js
class
MakoDescriptorSystem
(
DescriptorSystem
):
...
...
@@ -8,20 +13,19 @@ class MakoDescriptorSystem(DescriptorSystem):
self
.
render_template
=
render_template
class
Mako
ModuleDescriptor
(
XModuleDescriptor
):
class
Mako
TemplateBlockBase
(
object
):
"""
Module descriptor
intended as a mixin that uses a mako template
XBlock
intended as a mixin that uses a mako template
to specify the module html.
Expects the descriptor to have the `mako_template` attribute set
with the name of the template to render, and it will pass
the descriptor as the `module` parameter to that template
MakoModuleDescriptor.__init__ takes the same arguments as xmodule.x_module:XModuleDescriptor.__init__
"""
# pylint: disable=no-member
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Mako
ModuleDescriptor
,
self
).
__init__
(
*
args
,
**
kwargs
)
super
(
Mako
TemplateBlockBase
,
self
).
__init__
(
*
args
,
**
kwargs
)
if
getattr
(
self
.
runtime
,
'
render_template
'
,
None
)
is
None
:
raise
TypeError
(
'
{runtime} must have a render_template function
'
...
...
@@ -39,6 +43,21 @@ class MakoModuleDescriptor(XModuleDescriptor):
'
editable_metadata_fields
'
:
self
.
editable_metadata_fields
}
def
studio_view
(
self
,
context
):
# pylint: disable=unused-argument
"""
View used in Studio.
"""
# pylint: disable=no-member
fragment
=
Fragment
(
self
.
system
.
render_template
(
self
.
mako_template
,
self
.
get_context
())
)
shim_xmodule_js
(
self
,
fragment
)
return
fragment
class
MakoModuleDescriptor
(
MakoTemplateBlockBase
,
XModuleDescriptor
):
# pylint: disable=abstract-method
"""
Mixin to use for XModule descriptors.
"""
def
get_html
(
self
):
return
self
.
system
.
render_template
(
self
.
mako_template
,
self
.
get_context
())
return
self
.
studio_view
(
None
).
content
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment