Crop Cutter

I really like the Mako template system used by Pylons and a couple of other Python frameworks, and my only complaint is how WS flows through even a simple inheritance scheme.

Is there a way to execute below without creating such huge WS spaces ... or packing up my code, as I started doing with base.mako?

Otherwise, to understand what I'm trying to do below.

The base is like an interface class for all views for the entire application, the layout is just a prototype idea for 3-4 different layout files (tables, pure CSS, etc.), and the controller / action is a test to make sure my idea is reasonable .

Brief summary of the question: how to cut out the WS created in my Mako scheme?

Update: this is not a solution because it includes downloading all my mako files using 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}! 

displayed output:

 <!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> 
+4
source share
1 answer

Found my own answer http://docs.makotemplates.org/en/latest/filtering.html

It still required some trial and error, but using

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

dramatically reduces the gap. Additional savings can be found by checking the compiled template and looking for any entries that simply click "or similar."

+2
source

All Articles