本文介绍了PHP + TinyButStrong Python替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 喜!我是一个php用户和一个python程序员。我很乐意使用python来支付我的服务器方需要的b $ b但是我似乎无法找到我正在寻找的东西。对于 大多数我的php工作我使用mysql和tinyButStrong ( http://www.tinybutstrong.com )这是一个非常轻量级的模板 引擎,提供强大的功能。你在网上插入TBS标签 页面如: < div align =" center" class =" title-page" [var.x]< / div> 它将[var.x]替换为全局变量x的值。它还使得b $ b使块(和嵌套块)易于实现: < p class =" text-example2" [blk1; block = begin ] [blk1.val]< br> [blk1; block = end]< / p> 在之前的代码中循环数组blk1的值。 它做了很多东西,比如htlm转义,url和js编码等, 条件显示等,但它是将更多的代码插入HTML(又名:乱丢代码和亲吻 告别代码/演示文稿分离)并不会让人感到困惑。它有一个 单个文件的形式,单个类可以很容易地包含在代码中 然后去。 现在,我已经搜索了网络,它似乎充满了基于python的框架 用于服务器端脚本和模板,但没有一个适合我的 需求。 1.我喜欢编写代码,我喜欢控制。我的意思是,打开 最简单的文本编辑器并写入其中。我不想要一些是命令行驱动的或者为我编写代码的东西,比如>>> makePagesFromThisDatabase()。 2.我想要一些非常轻巧的东西。我不想要十几个选项, 预制博客部分ecc。我只需要一个好的非侵入式模板 引擎和服务器端脚本的基本功能,比如会话 管理,请求解析,操作html代码的功能(编码等) 3.我不想请求我的托管服务提供商安装库。 a简单包含文件应该可以正常工作。 4.不需要面向对象的编程(更好:我更喜欢 普通的旧程序编程)。 任何帮助?提前谢谢 解决方案 你看过TurboGears还是Django? TG使用1.x系列中的Kid 和2.x(我认为)中的Genshi用于模板目的。还有 Cheetah,一个比较强大的Python模板引擎。 http://genshi.edgewall.org/ http://www.kid-templating.org/ http://www.cheetahtemplate.org/ http: //turbogears.org/ 也许这些链接可以帮助你。 Mike 感谢重播 django非常棒的那种巨人我我试图避免 教程的第一行: "首先,确保你安装了CherryPy 3.0.x" ; 现在,cherrypy是不正确的包含文件并获得 ! 孩子似乎有一个非线性的方法,但我可以尝试一下 猎豹是我已经考虑过的东西。我要 " install"它或者我可以导入它吗? 和django一样的问题! 感谢重播 django是一种巨人,我正在尝试避免 教程的第一行: "首先,确保你有CherryPy 3.0。 x安装了 现在,cherrypy是一个不正确的东西包括一个文件并获得 ! 孩子似乎有一个非线性方法,但我可以尝试一下 猎豹是我已经考虑过的东西。我要 " install"它还是我可以导入它? 您需要安装其中任何一个。它是python如何设计的一部分。 可扩展性带有价格标签。 我不确定,但我猜genshi的樱桃要求是 更多的教程,而不是模板本身。 Diez hi! i''m a php user and a python programmer. i''d love to use python formy server side needs but i can''t seem to find what i''m looking for. formost of my php work i use mysql and tinyButStrong(http://www.tinybutstrong.com) which is a very lightweight templateengine that offers powerful functionalities. you insert TBS tags in webpages like:<div align="center" class="title-page"[var.x] </div>and it replaces [var.x] with the value of global variable x. it alsomakes blocks (and nested blocks) easy to implement:<p class="text-example2"[blk1;block=begin] [blk1.val]<br>[blk1;block=end] </p>in the previous code it cycles throu all the values of the array blk1.it does many more things, like htlm escaping, url and js encoding etc,conditional displaying etc, but it is not more confusing that insertingpieces of code into the HTML (aka: littering the code and kissinggoodbye to the code/presentation separation). it comes in the form of asingle file with a single class that you can easily include in the codeand go.now, i''ve searched the net and it seems full of python-based frameworksfor doing server side scripting and templating, but none that suits myneeds.1. i like writing code and i like control. i mean, open up thesimplest text editor and write in it. i don''t want something that iscommand-line driven or that writes code for me like ">>>makePagesFromThisDatabase()".2. i want something very lightweight. i don''t want dozen of options,pre-made blogging parts ecc. i just need a good non invasive templateengine and the basic functions for server side scripting, like sessionmanaging, request parsing, functions to manipulate html code (encodings etc)3. i don''t want to beg my hosting provider to install the libraries.a simple include file should do the work.4. object oriented programming is not required (better: i preferplain old procedural programming).any help? thanks in advance 解决方案Did you look at TurboGears or Django? TG uses Kid in the 1.x seriesand Genshi in 2.x (I think) for templating purposes. There''s alsoCheetah, one of the more powerful Python templating engines out there. http://genshi.edgewall.org/ http://www.kid-templating.org/ http://www.cheetahtemplate.org/ http://turbogears.org/Maybe those links will get you going.Mikehi, thanks for replayingdjango is exacly the kind of giant i''m trying to avoidthe first lines of the tutorial read:"First, make sure you have CherryPy 3.0.x installed"Now, cherrypy is something that is not properly "include a file and getgoing!"kid seems to have a non-linear approach, but i may give it a trycheetah was something that i already considered using. have i to"install" it or can i just import it?same problem as with django!hi, thanks for replayingdjango is exacly the kind of giant i''m trying to avoidthe first lines of the tutorial read:"First, make sure you have CherryPy 3.0.x installed"Now, cherrypy is something that is not properly "include a file and getgoing!"kid seems to have a non-linear approach, but i may give it a trycheetah was something that i already considered using. have i to"install" it or can i just import it?You will need to install any of these. It is part of how python is designed.Extendability comes with a price-tag.I don''t know for sure, but I guess the cherrypy-requirement of genshi ismore for the tutorial, not for the templating itself.Diez 这篇关于PHP + TinyButStrong Python替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-03 18:53