groue / GRMustache

Flexible and production-ready Mustache templates for MacOS Cocoa and iOS
http://mustache.github.com/
MIT License
1.44k stars 190 forks source link

Variable name with spaces #63

Closed l4u closed 11 years ago

l4u commented 11 years ago

Not sure if this is in the spec, but the python implementation pystache can render {{ variable name}}.

import pystache
print pystache.render('{{ with space }}',{'with space':'content'})

Is there any way we can render this in GRMustache without throwing an error for compatibility? Because I got data in this format. Thanks!

groue commented 11 years ago

Hi l4u,

From https://github.com/mustache/spec/blob/master/specs/interpolation.yml :

The tag's content MUST be a non-whitespace character sequence NOT containing the current closing delimiter.

So, no, I won't update GRMustache for that.

I would instead open an issue in the pystache repo, so that no more people get bitten by this inconsistency.

Sorry. I hope you don't have too many keys to update.

l4u commented 11 years ago

Thanks, I've posted it at https://github.com/defunkt/pystache/issues/156

l4u commented 11 years ago

@groue may I know which file/lines I should look into? I know this isn't following the specs but I will have to parse those malformed data.

groue commented 11 years ago

@l4u I did not understand your last question. How may I help you?

l4u commented 11 years ago

I am trying to allow tags with white spaces. seems that it works if I remove the line at https://github.com/groue/GRMustache/commit/dcaa98a891918f7b1054dc92f56976bb1f589201#diff-203bc92a75f3e65b4230515df363c513R208 I am not saying this should be merged :smile: it's just for my special use case

groue commented 11 years ago

I guess it would work, yes. So go ahead if you prefer this option.

groue commented 11 years ago

Of course the best option is to stop using white spaces in your keys, and this is what I advise you to do.

l4u commented 11 years ago

Yeah, but unfortunately the mustache templates are out of my control. They are from 3rd parties. :cry:

groue commented 11 years ago

Well, in that case... You can send them the links to the pystache issue, and to the spec (https://github.com/mustache/spec/blob/master/specs/interpolation.yml). So that they stop producing invalid templates. Eventually. Maybe :smile: