how to avoid hard-coding urls in webapp templates
-
03-07-2019 - |
Question
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..
Solution
WebApp is really very basic.
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.
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).
OTHER TIPS
Webapp uses Django templates so: check out Django templates here
The Django solution is the web app solution.