pystache command always treats template argument as string
Opened this issue · 3 comments
The command line version of pystache always treats the template argument as a string. Based on the documentation, it should recognize a file if one exists, which is how the context argument currently works.
echo "Hello {{world}}" > template
echo '{"world": "everybody"}' > context
# expecting "Hello everybody" but the actual result is "template"
pystache template context
pystache/pystache/commands/render.py
Line 72 in 17a5dfd
It seems like unless the template input ends in .mustache
it won't try to consider it as a filename.
Actually it seems like it work as advertised for me now (pystache==0.5.4). . . even with my own test case posted above. I'm not sure why I was seeing this before . . .
Edit . . . nevermind. You are correct. I had a .mustache template hanging around which is why I thought my original test case was working.
pystache template context
will automatically look for 'template.mustache' and use that if found.
Three years after this was originally reported, I had to dig through source code and issues to find out that it expects filenames ending with the magic string .mustache
.
I recommend adding --context-file
, --context-string
, --template-file
, and --template-string
.
This leaves alone the behavior of the overloaded positional arguments, in case some users depend on that behavior.
Update: now that I've got pystache3
working, I just want you to know that I find it quite useful. Thanks!