一个用于金字塔的javascript模板的实时编译和打包。
pyramid_jitt的Python项目详细描述
金字塔jitt包是jstcjavascript的包装。 允许在中定义客户端模板的模板编译器 完全不同的服务器端文件,并进行组装、预编译、打包, 缓存,并对内联、延迟和受限的访问进行控制 交货。
重要
截至2016/10/09,“受限”交付(即访问控制 所有模板或模板子集的交付控制)和 按模板jit呈现尚不可用。
目前,非内联模板需要jQuery(v1.9.1+) 交货。
项目
安装
$ pip install pyramid_jitt
用法
在ini文件中通过以下方式启用包:
pyramid.includes= pyramid_beaker pyramid_jitt
(强烈建议使用pyramid_beaker缓存 呈现的模板)或包应用程序中的代码 初始化方式:
defmain(global_config,**settings):# ...config.include('pyramid_beaker')config.include('pyramid_jitt')# ...
通过设置 您的ini文件(有关详细信息,请参见Manual),例如:
# use pyramid_beaker for caching!cache.type=memorycache.regions=pyramid_jittcache.pyramid_jitt.expire=3600# override all template attributes to disable deferred loadingjitt.overrides.inline=true# define where the "webapp" templates (Handlebars, in this case) are# located and disable pre-compilation (only for "webapp" templates)jitt.@webapp.assets=myapp:static/scripts/**.hbsjitt.@webapp.overrides.precompile=false
然后,将传递负载添加到html文件中,这里是Mako 示例:
<html> <body> ${request.registry.jitt.render('webapp')|n} <script type="text/javascript"> // NOTE: this must come **after** the `jitt.render` call! $(function() { $('#Templates').data('jitt').ready(function() { // start your client-side app that uses your templates here!... }); }); </script> </body> </html>
更多文档
更多文档可以在Manual中找到。