GithubHelp home page GithubHelp logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
Is the content of a {%...%} or {{...}} arbitrary python or is it restricted to 
python
identifiers?

Original comment by [email protected] on 14 Jan 2009 at 8:19

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
Oh, and to avoid unnecessarily introducing multi-line tokens into HTML, can the
{%...%} or {{...}} constructs contain newline characters or the < character?  
If so,
is it common for them to?

Original comment by [email protected] on 14 Jan 2009 at 9:47

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
Mike, the contents of both {%...%} (template tags) and {{...}} (variables, 
possibly
piped through filters), can potentially be anything in Unicode space. The first
"word" will typically be similar to a Python identifier, but the remainder are
arguments which can be arbitrary strings.

Neither grouping can contain newlines. They're unlikely to contain things like 
the
'<' character. Experience (fwiw) suggests that the most likely things are going 
to be
alphanumeric characters (including alphabetic characters outside the ASCII 
range, and
that does happen as the Django international audience is huge), whitespace and 
double
and single quotes. The rest are legal (except for newlines), but less common.

Original comment by [email protected] on 19 Jan 2009 at 5:58

from google-code-prettify.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 23, 2024
Thanks.  

Are they typically short?

I ask since if I can't distinguish HTML source from HTML containing Django 
template
groups, I want to be able to come up with a definition that admits few false 
positives.

The definitions I'm leaning towards so far are:
  /\{\{[^\0xa-0xd\x85\u2028\u2029]{2,40}?\}\}/
and
  /\{\%[^\0xa-0xd\x85\u2028\u2029]{2,40}?\%\}/

http://docs.djangoproject.com/en/dev/topics/templates/#topics-templates 
describes the
content as a language that has a few keywords, pythonesque identifiers, uses | 
and :
for piping and parameterization, and which has numeric and double-quoted string
literals, without string interpolation.  It's unclear whether it has reserved
keywords but that distinction isn't important to me.

Original comment by [email protected] on 20 Jan 2009 at 11:45

  • Changed state: Accepted

from google-code-prettify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.