Python Pylons WebHelper 表示しているページのURL取得(h.current_url) |
webhelpers.rails.urls
current_urlで、現在表示しているURLの相対パスを取得できます。
以下のように記述すると
${h.current_url()}
現在のURLの相対パスが取得できます。
例)
http://localhost:5000/makotest/unless_current
で表示させると
/makotest/unless_current
idやパラメータの指定も可能
${h.current_url(id=10, p='param')}
例)
http://localhost:5000/makotest/unless_current
で表示させると
/makotest/unless_current/10?p=param
別なactionももちろん指定できます。
${h.current_url(action='test_url', id=10, p='param')}
例)
http://localhost:5000/makotest/unless_current
で表示させると
/makotest/test_url/10?p=param