mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 07:57:55 +03:00 
			
		
		
		
	Prefer format and use named blocks
				
					
				
			This commit is contained in:
		
							parent
							
								
									4947303f20
								
							
						
					
					
						commit
						ef1fb3d8df
					
				|  | @ -41,7 +41,7 @@ def optional_login(request): | |||
|     except NoReverseMatch: | ||||
|         return '' | ||||
| 
 | ||||
|     snippet = "<li><a href='%s?next=%s'>Log in</a></li>" % (login_url, escape(request.path)) | ||||
|     snippet = "<li><a href='{href}?next={next}'>Log in</a></li>".format(href=login_url, next=escape(request.path)) | ||||
|     return snippet | ||||
| 
 | ||||
| 
 | ||||
|  | @ -53,19 +53,19 @@ def optional_logout(request, user): | |||
|     try: | ||||
|         logout_url = reverse('rest_framework:logout') | ||||
|     except NoReverseMatch: | ||||
|         return '<li class="navbar-text">{0}</li>'.format(user) | ||||
|         return '<li class="navbar-text">{user}</li>'.format(user=user) | ||||
| 
 | ||||
|     snippet = """<li class="dropdown"> | ||||
|         <a href="#" class="dropdown-toggle" data-toggle="dropdown"> | ||||
|             {0} | ||||
|             {user} | ||||
|             <b class="caret"></b> | ||||
|         </a> | ||||
|         <ul class="dropdown-menu"> | ||||
|             <li><a href='{1}?next={2}'>Log out</a></li> | ||||
|             <li><a href='{href}?next={next}'>Log out</a></li> | ||||
|         </ul> | ||||
|     </li>""" | ||||
| 
 | ||||
|     return snippet.format(user, logout_url, escape(request.path)) | ||||
|     return snippet.format(user=user, href=logout_url, next=escape(request.path)) | ||||
| 
 | ||||
| 
 | ||||
| @register.simple_tag | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user