2010-07-03 2 views
0

치타에서 정적 메소드를 선언 할 수있는 방법이 있습니까? IE치타의 Un/bound 메소드

#from snippets import * 

$snippets.address($home_address, "home address") 

이 코드이 오류를보고

#def address($address, $title) 
<div class="address"> 
<b>$title</h1></b> 
#if $address.title 
$address.title <br/> 
#end if 
$address.line1 <br/> 
#if $address.line2 
$address.line2 <br/> 
#end if 
$address.town, $address.state $address.zipcode 
</div> 
#end def 

.... 

other snippets 

other.tmpl snippets.tmpl : NotFound: cannot find 'address'. 치타는 바인딩 방법 답다로 컴파일 :

class snippets(Template): 

    ... 

    def address(self, address, title, **KWS): 

정적 메소드를 선언 할 수있는 방법이 있나요을 snippets.py? 그렇지 않다면 이와 같은 것을 구현할 수있는 대체 방법은 무엇입니까 (스 니펫 라이브러리)?

+0

치타에 대한 구문 강조 표시는 좋지 않습니다 ... – colinmarc

답변

0

This page에는 관련 정보가있는 것 같지만 지금은 직접 사용해보아야합니다.

#@staticmethod 
#def address($address, $title) 

을 ... 그리고 작동이 :

특히, 당신은 할 수 있어야합니다.

(모르는 경우 staticmethod은 ... 정적 방법을 만드는 내장 함수입니다. 가장 일반적으로 decorator으로 사용됩니다. 그래서 나는 그 페이지를 Google 검색 "cheetah staticmethod"로 찾았습니다.

+0

아, 내 치타 정적 방법에 대한 검색은 저를 얻지 못했습니다. 이걸 시험해 보겠습니다. – colinmarc

+0

그래, 구문보다는 함수 이름을 사용하면 상당히 좁혀지는 경향이 있습니다. – detly

관련 문제