How to implement "url" tag?

3 views
Skip to first unread message

Anton Danilchenko

unread,
Feb 9, 2011, 4:42:02 AM2/9/11
to gaefra...@googlegroups.com
Hello!

We need to implement template tag {% url app_name action_name param1=val1 %} to use in templates. Similar tags we can find in Django and other projects. Idea is in get absolute url address of page with given action with given properties list.

For example, this tag {% url blog new_entry blog=blog %} transforms to "/blog/antons_blog/create_entry".

If you have ideas about how to implement this in very easy way - please tell me. Or, provide code to solve this issue. Thanks!

Anton Danilchenko

unread,
Feb 10, 2011, 3:44:26 AM2/10/11
to gaefra...@googlegroups.com
 have solved this issue. In few hours I will push changes to server.

You can do this in templates:
{% url blog.edit_entity entity=entity.key.name %}
and you need for this define special "tag" option in urls mapping in your application config.yaml file like this:
urls:
- url: :entity/edit
  run: entity_edit
  tag: edit_entity
Enjoy!

Anton Danilchenko

unread,
Feb 10, 2011, 4:06:51 AM2/10/11
to gaefra...@googlegroups.com
Improved syntax. Now you can pass model instance as variable, and we automatically transform this variable to key name, or key numeric id or key representation (depends on what is available).

You can do this:
{% url blog.edit_entry entity=entity %}
instead of old syntax (also supported):
Reply all
Reply to author
Forward
0 new messages