flask模板使用layui前端框架语法冲突

 大致报错如下吧. {{ 很容易冲突. 

File "D:\soft\Python27\lib\site-packages\jinja2\environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "D:\soft\Python27\lib\site-packages\jinja2\loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "D:\soft\Python27\lib\site-packages\jinja2\environment.py", line 591, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "D:\soft\Python27\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "d:\work\python\xycdn\templates\rule_add.html", line 58, in template
<option value="1" {{ # if(d.rule_type == 1){}} selected{{ #}}}>鏂囦欢绫诲瀷</option>
TemplateSyntaxError: unexpected char u’#’ at 1794

解决办法:

原始语句: {{# if(d.rule_type == 1){}} selected{{# }}}
修改后: {{" {{# if(d.rule_type == 1){}} selected{{# }}}"}}

其实就是在冲突的代码前后 增加 {{"冲突的代码"}}, 这样就会当作 字符串输出了.

没有评论 to “flask模板使用layui前端框架语法冲突”

留下评论:

昵称(必须):
邮箱地址 (不会被公开) (必须):
站点
评论 (必须)
XHTML: 您可以使用这些标记: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>