Задать вопрос

Тел: +7 965 3737 888

435

Просмотров

0

Ответов

Plaintext format (advanced spaceless)

<p>A template loader useful for writing templates with carefully controlled newlines and spaces while retaining readable template source code formatting.</p>
<p>Start the template with PTFTAG ({#ptfable#}, here) to allow it to be processed.  Common problems with doing it to most templates as-is is use of newlines to separate words and multiple spaces between tags where spaces are still needed (which is problematic with spaceless tag as well).</p>
<p>Currently intended as a template loader wrapper, and is suggested to be used with cached loader.  Example settings.py configuration:</p>
_lp = lambda lo, *ar: (lo, ar,)  # loader, arguments
TEMPLATE_LOADERS = (
  _lp('django.template.loaders.cached.Loader',  # cache
    _lp('ptf.template.ptftemplateloader.Loader',  # ptf
     'django.template.loaders.filesystem.Loader',
     'django.template.loaders.app_directories.Loader',
     #'django.template.loaders.eggs.load_template_source'
    ),  # ptf
  ),  # cache
)

<p>(change ptf. to wherever in python path you've put it).</p>
<p>You might also need couple of simple template tags for explicitly inserting newlines or whitespaces:</p>
def br():
    return "\n"
br = register.simple_tag(br)
# XHTML-XMPP-template compatible.
def brx():
    return "&lt;br /&gt;\n"
brx = register.simple_tag(br)
def ws():
    return " "
ws = register.simple_tag(ws)

<p>.</p>

Вопрос полезен? Да0/Нет0
file_5140.py(2.0Кб)
None