6

I did't find it written explicitly in the docs.

Are the naming rules the same as with Python variables?

(eg: {{ a_variable'like_that' }} doesn't work for example)

lajarre
  • 4,910
  • 6
  • 42
  • 69
  • Why do you want to know? If it doesn't work, use another name. – dAnjou Jul 16 '13 at 23:34
  • 3
    @dAnjou pretty surprising reaction! Feels misplaced... I need to build a jinja template from text that already has its own (decoupled) tagging syntax, which is not having such limitation on variables names (placeholders). Thus, I need to know that to build a robust translator. I didn't find a jinja forum / mailing list, so I told myself I would just post my question on SO. I will let other users judge if it's worthwhile – lajarre Jul 17 '13 at 08:36
  • It's not inappropriate. Many beginner programmers want to do weird stuff. So I better ask *why* they want to do it so that I can give better support. Back to your question: to be safe, make sure those names are [`\w+`](http://en.wikipedia.org/wiki/Regular_expression#Character_classes). And you didn't find what? http://jinja.pocoo.org/community/ – dAnjou Jul 17 '13 at 10:03
  • 2
    Ok fine. And for sure I didn't look correctly for the jinja community page! Must have had my mind somewhere else. But "whatever", I think this question has its place on SO as well, deserves to be answered and finally most of all to be written in the doc. – lajarre Jul 17 '13 at 10:49
  • 1
    Report a bug: https://github.com/mitsuhiko/jinja2/issues/new – dAnjou Jul 17 '13 at 11:58

1 Answers1

1

Jinja's naming convention generally matches your python interpreter's identifiers. So it also depends on your Python version (2.x: like [a-zA-Z_][a-zA-Z0-9_]*)

(source: #pocoo on irc.freenode.net)

lajarre
  • 4,910
  • 6
  • 42
  • 69