def get_assets(asset_type):
path = os.path.join(current_app.root_path, current_app.config['TEMPLATE_FOLDER'], 'assets.json')
assets = json.load(open(path, 'r'))
output = ''
if asset_type == 'css':
output = '<link rel="stylesheet" href="{0}">'.format(assets['style']['css'])
elif asset_type == 'js':
manifest = assets['manifest']['js']
manifest = manifest[1:]
manifest_file = open(os.path.join(current_app.root_path, current_app.config['STATIC_FOLDER'], manifest), 'r')
output += '<script>' + manifest_file.read() + '</script>'
manifest_file.close()
output += '<script src="{0}"></script>'.format(assets['vendor']['js'])
output += '<script src="{0}"></script>'.format(assets['app']['js'])
return jinja2.Markup(output)
评论列表
文章目录