Skip to content

Commit

Permalink
- filename context added to template call in mako-render,
Browse files Browse the repository at this point in the history
so that inheritance chains and includes are located
correctly, [ticket:202]
  • Loading branch information
zzzeek committed Mar 21, 2013
1 parent 717c0b6 commit aa3c98e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/mako-render
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python

def render(data, kw):
def render(data, filename, kw):
from mako.template import Template
from mako.lookup import TemplateLookup

lookup = TemplateLookup(["."])
return Template(data, lookup=lookup).render(**kw)
return Template(data, filename, lookup=lookup).render(**kw)

def varsplit(var):
if "=" not in var:
Expand All @@ -28,7 +28,7 @@ def main(argv=None):

opts, args = parser.parse_args(argv[1:])
if len(args) not in (0, 1):
parser.error("wrong number of arguments") # Will exit
parser.error("wrong number of arguments") # Will exit

if (len(args) == 0) or (args[0] == "-"):
fo = stdin
Expand All @@ -40,7 +40,7 @@ def main(argv=None):

kw = dict([varsplit(var) for var in opts.var])
data = fo.read()
print render(data, kw)
print render(data, filename, kw)

if __name__ == "__main__":
main()

0 comments on commit aa3c98e

Please sign in to comment.