문제

나는 철탑과 몇 개의 다른 Python 프레임 워크에 사용되는 Mako 템플릿 시스템을 정말로 좋아하며, 유일한 불만은 간단한 상속 체계를 통해 WS가 얼마나 많이 누출되는지입니다.

어쨌든 큰 WS 갭을 만들지 않고 아래에서 달성 할 수 있습니까?

그렇지 않으면 내가 아래에서 달성하려는 것에 대한 그립을 얻으려면.

베이스는 전체 애플리케이션의 모든보기에 대한 인터페이스 클래스와 비슷하며 레이아웃은 3-4 개의 다른 레이아웃 파일 (테이블, 순수한 CSS 등)에 대한 프로토 타입 아이디어 일 뿐이며 컨트롤러/액션은 내 아이디어가 있는지 확인하는 테스트입니다. 제정신.

간단한 질문 요약 : 마코 체계에서 만든 WS를 잘라내는 방법은 무엇입니까?

업데이트 : 솔루션이 아닙니다. http://www.makotemplates.org/docs/syntax.html#syntax_newline

/base.mako

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head><%def name="headtags()"></%def>${self.headtags()}</head>
  <body>
    <%def name="header()"></%def>${self.header()}${next.body()}<%def name="footer()"></%def>${self.footer()}
  </body>
</html>

/layout.mako

<%inherit file="/base.mako"/>
<%def name="headtags()">
   ${parent.headtags()}
   <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>
</%def>
<%def name="header()">
  <h1>My Blogination</h1>
</%def>
<div id="content">${next.body()}</div>

/controller/action.mako

<%inherit file="/layout.mako" />
<%def name="headtags()">    
    <title> Hello world, templating system is 1 percent done</title>
    ${parent.headtags()}
</%def>
Hello ${c.name}! 

렌더링 된 출력 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>    
    <title> Hello world, templating system is 1 percent done</title>

   <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js"></script>


</head>
  <body>

  <h1>My Blogination</h1>


<div id="content">

Hello Anonymous!

</div>

  </body>
</html>
도움이 되었습니까?

해결책

내 대답을 찾았습니다http://docs.makotemplates.org/en/latest/filtering.html

여전히 시행 착오가 필요했지만 사용

t = TemplateLookup(directories=['/tmp'], default_filters=['trim'])

공백 출혈을 극적으로 줄입니다. 컴파일 된 템플릿을 확인하고 단지 푸시하는 글을 찾으면 추가 비용을 찾을 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top