defunkt / pystache

Mustache in Python
http://mustache.github.com/
MIT License
1.31k stars 308 forks source link

the tag containing whitespaces should throw an error #156

Open l4u opened 10 years ago

l4u commented 10 years ago
import pystache
print pystache.render('{{ with space }}',{'with space':'content'})

Currently, this (pystache 0.5.3) works without errors.

l4u commented 10 years ago

In ruby's implementation, an error will occur

require 'mustache'
Mustache.render('{{ with space }}', {'with space' => 'content'})

Mustache::Parser::SyntaxError: Unclosed tag

l4u commented 10 years ago

Related to https://github.com/mustache/spec/issues/67 https://github.com/mustache/spec/blob/master/specs/interpolation.yml

bobthecow commented 10 years ago

According to the spec, that's a valid tag name. The only things that a tag name can't contain are . and the closing delimiter (and they can't start with any of the tag sigils — &, =, >, etc — unless they're inside a tag that already has a sigil, so I'd avoid starting with them regardless).

I'd consider this a bug in the Ruby implementation :)

l4u commented 10 years ago

An Objective-C implementation (https://github.com/groue/GRMustache) and a ruby implementation (https://github.com/mustache/mustache) do not allow spaces. While this python implementation, or possibly your php implementation allow spaces. I hope that someone could clarify the specs.

bobthecow commented 10 years ago

If you have a python dictionary or a PHP associative array with spaces in the keys, it's perfectly valid to use tags with spaces to get at them.