您是否看过: https: //github.com/kakulukia/pypugjs?
似乎支持 Jinja2:
jinja_env = Environment(extensions=['pypugjs.ext.jinja.PyPugJSExtension'])
Run Code Online (Sandbox Code Playgroud)
下面的哈巴狗(玉石)代码示例
!!! 5
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) {
bar()
}
body
h1.title PugJS - node template engine
#container
if youAreUsingPugJS
p You are amazing
else
p Get on it!
Run Code Online (Sandbox Code Playgroud)
转换为:
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{pageTitle}}</title>
<script type='text/javascript'>
if (foo) {
bar()
}
</script>
</head>
<body>
<h1 class="title">PugJS - node template engine</h1>
<div id="container">
{%if youAreUsingPugJS%}
<p>You are amazing</p>
{%else%}
<p>Get on it!</p>
{%endif%}
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
您可以使用以下实用程序命令来执行此操作:
pypugjs -c jinja input.pug output.html
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3163 次 |
| 最近记录: |