我将从python方法向mako模板传递几个变量
假设变量是这样的
var_1 = "mentor_name"
var_2 = "mentor_pic_link"
var_3 = "<div><p>${var_1} has posted this pic ${var_2}</p></div>"
{var_1
和var_2
内的var_3
我尝试了文本替换,但不能对多个变量进行替换
代码如下所示
def send_data_to_mako():
fragment_context = {
'var_1': "mentor_name",
'var_2': "mentor_pic_link",
'var_3': "<div><p>${var_1} has posted this pic ${var_2}</p></div>",
}
fragment.add_content(self.system.render_template('vert_module.html', fragment_context))
<%page expression_filter="h"/>
<%! from openedx.core.djangolib.markup import HTML %>
<div class="vert-mod">
${HTML(var_3)}
</div>
目前产出:
${var_1} has posted this pic ${var_2}
预期产出:
mentor_name has posted this pic mentor_pic_link
目前没有回答
相关问题 更多 >
编程相关推荐