问题标签 [mako]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Mako 从字符串调用函数?
有没有一种简单的方法可以在 mako 中调用给定字符串名称的函数?
python - Pylons + Mako -- 从模板访问 POST 数据
如何使用 Pylons 从我的 Mako 模板访问我的 request.params 发布数据?
python - 从 Mako 模板输出 (Pylons) 中去除空格
我正在使用 Mako + Pylons,我注意到我的 HTML 输出中有大量的空白。
我将如何摆脱它?Reddit 设法做到了。
python - 用 Mako 替换字符串中的命名
在 Mako 中创建模板时,我需要编写如下内容:${_('Hello, %(fname)s %(lname)s') % {'fname':'John','lname':'Doe'}}
我在编写时解析时不断收到 SyntaxException: (SyntaxError) unexpected EOF。有没有办法做同样的事情?
${_('Hello, %s %s') % ('John', 'Doe')}
有效,但如果需要,它不允许在更改语言时更改替换顺序。
谢谢。
python - 截断 mako 模板中的字符串
如果太长,我想找到一种方法来截断标题,如下所示:
有没有办法在 mako 中打印一个字符串,如果超过一定数量的字符,会自动用“...”截断?
谢谢。
python - 条件 mako 基础模板从继承一个
我有一个带有 if 语句的 base.mako 模板来包含或不包含 jQuery
有几个模板继承自 base.mako,有人需要 jQuery,有人不需要。
目前我必须在调用渲染之前在控制器中设置属性
但我认为这应该直接进入子模板(即jQueryTemplate.mako)
我尝试在继承之前添加它
但它不起作用。
有小费吗?
谢谢你的支持
python - Best Practices for Python UnicodeDecodeError
I use Pylons framework, Mako template for a web based application. I wasn't really bother too deep into the way Python handles the unicode strings. I had tense moment when I did see my site crash when the page is rendered and later I came to know that it was related to UnicodeDecodeError.
After seeing the error, I started mesh around my Python code adding encode, decode calls for string with 'ignore' option but still I could not see the errors gone sometime.
Finally I used to decode to ascii with ignore and made the site running without any crash.
Input to my site comes through many sites. This means that I do not control the languages or language of choice. My site supports international languages and along with English. I have feed aggregation which generally not bother about unicode/ascii/utf-8. While I display the text through mako template, I display as it is.
Not being a web expert, what are the best practices to handle the strings within the Python project? Should I care only while rendering the text or all the phase of the application?
google-app-engine - 带有 Google App Engine 的 Mako 模板
我想将 Mako 模板与 GAE 一起使用,而不是 Django 模板。我发现这篇文章http://blog.pansapiens.com/2008/06/24/mako-templates-in-google-app-engine-seems-to-work-for-me/
我使用easy_install http://www.makotemplates.org/download.html从这个页面下载了Mako
但这给了我一个“烧杯”文件
c:\python26\lib\site-packages\beaker-1.5.4-py2.6.egg
我不知道该怎么办。
有人可以帮助我,以便我可以按照博客中的说明将“Mako”文件放入我的 GAE 目录中。
我在这里看到了对 Mako/GAE 的引用Google App Engine--Dynamically created templates
谢谢你。
python - 在 Mako 中编码 JSON?
我在 mako 中遇到 json 问题。我这样做:
其中 to_json 是:
然而,而不是给我
它给了我
所以mako在某处改变了“to”
我应该怎么做呢?
相反,这是一个测试脚本
输出
编辑
我将我的功能更改为
并且它将 " 更改为"
,因此它似乎是 mako 的问题。
google-cloud-datastore - 使用 Mako 模板在 Google App Engine 中搜索表单
脚本在 data.py 中,模板文件是 search.mako。搜索表单在 MainPage 方法中(不包含在下面的代码中)。我输入了搜索词,但没有任何反应。你能帮助理解我做错了什么吗?谢谢你。
这就是 search.mako