템플릿 사용을 위해 내 웹 세트와 마코를 구성하기 위해 flask-assets을 사용하고 싶습니다.플라스크 - 마코와 함께 플라스크 - 자산 사용
:% assets 'coffee':
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
% endassets
그러나 이것은 컴파일 오류가 발생합니다 다음과 같은 것이다 (내가 아는 한)
{% assets "js_all" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
마코에 해당 : 플라스크-자산은 일반적으로 다음과 같은 방법으로 신사를 사용
mako.exceptions.CompileException
CompileException: Unsupported control keyword: 'assets' in file '/index.html' at line: 8 char: 1
Mako에서 맞춤 자산 컨트롤 키워드 (예 : '애셋')를 사용할 수 있습니까?
import os
from flask import Flask, render_template
from flask.ext import assets
from flask import config
from flask.ext.mako import MakoTemplates
from flask.ext.mako import render_template
app = Flask(__name__)
app.config['ASSETS_DEBUG'] = True
mako = MakoTemplates(app)
env = assets.Environment(app)
# Tell flask-assets where to look for our coffeescript and sass files.
env.load_path = [
os.path.join(os.path.dirname(__file__), 'js'),
os.path.join(os.path.dirname(__file__), 'styles'),
]
coffee = assets.Bundle('**/*.coffee', filters='coffeescript', output="app.js")
env.register('coffee', coffee)
@app.route("/")
def index():
return render_template('index.html', name='mako')
if __name__ == "__main__":
app.run(debug=True)