I'm developing software on google app engine. I'm using the webapp framework. is there any way to avoid hard-coding urls in the html templates? django provides a solution, but I couldn't find one for webapp. thanks in advance..
我正在谷歌应用引擎上开发软件。我正在使用webapp框架。有没有办法避免在html模板中硬编码网址? django提供了一个解决方案,但我找不到一个用于webapp的解决方案。提前致谢..
2 个解决方案
#1
WebApp is really very basic.
WebApp非常基础。
Django url
templatetag is closely tied to its idea of URL resolving by matching regex patterns. As WebApp does not have any serious URL resolver, I imagine this would be really hard task to implement something in this line.
Django url templatetag与匹配正则表达式模式的URL解析密切相关。由于WebApp没有任何严肃的URL解析器,我认为在这一行中实现一些东西真的很难。
But you are not totally out of luck. Werkzeug has very easy to understand yet powerful URL routing mechanism that allows for reversing urls. You can try to base your implementation on this one (or throw away WebApp and use Werkzeug ;), it's really worth a try).
但你并非完全没有运气。 Werkzeug具有非常容易理解但功能强大的URL路由机制,允许反转URL。您可以尝试将此实现基于此实现(或丢弃WebApp并使用Werkzeug;),这真的值得一试)。
#2
Webapp uses Django templates so: check out Django templates here
Webapp使用Django模板:在这里查看Django模板
The Django solution is the web app solution.
Django解决方案是Web应用程序解决方案。
#1
WebApp is really very basic.
WebApp非常基础。
Django url
templatetag is closely tied to its idea of URL resolving by matching regex patterns. As WebApp does not have any serious URL resolver, I imagine this would be really hard task to implement something in this line.
Django url templatetag与匹配正则表达式模式的URL解析密切相关。由于WebApp没有任何严肃的URL解析器,我认为在这一行中实现一些东西真的很难。
But you are not totally out of luck. Werkzeug has very easy to understand yet powerful URL routing mechanism that allows for reversing urls. You can try to base your implementation on this one (or throw away WebApp and use Werkzeug ;), it's really worth a try).
但你并非完全没有运气。 Werkzeug具有非常容易理解但功能强大的URL路由机制,允许反转URL。您可以尝试将此实现基于此实现(或丢弃WebApp并使用Werkzeug;),这真的值得一试)。
#2
Webapp uses Django templates so: check out Django templates here
Webapp使用Django模板:在这里查看Django模板
The Django solution is the web app solution.
Django解决方案是Web应用程序解决方案。