Quantcast
Channel: Mako: Ticket Query
Viewing all articles
Browse latest Browse all 38

#202: mako-render doesn't give the lead template filesystem context.

$
0
0
  • scripts/mako-render

    a b  
    11#!/usr/bin/env python 
    22 
    3 def render(data, kw): 
     3def render(data, filename, kw): 
    44    from mako.template import Template 
    55    from mako.lookup import TemplateLookup 
    66 
    77    lookup = TemplateLookup(["."]) 
    8     return Template(data, lookup=lookup).render(**kw) 
     8    return Template(data, filename=filename, lookup=lookup).render(**kw) 
    99 
    1010def varsplit(var): 
    1111    if "=" not in var: 
     
    4040 
    4141    kw = dict([varsplit(var) for var in opts.var]) 
    4242    data = fo.read() 
    43     print render(data, kw) 
     43    print render(data, filename, kw) 
    4444 
    4545if __name__ == "__main__": 
    4646    main() 

test:

base.mako sub/base.mako -> <%inherit file="/base.mako"/> sub/index.mako -> <%inherit file="base.mako"/>


Viewing all articles
Browse latest Browse all 38

Trending Articles