views:

389

answers:

1

Help please with a django custom tag. Analize it please!

Idea:

  1. In any template (parent or child), we installing a tag {{ telepoint "head" }}, with a name, such putters could be more than one.

  2. At other side, we have block

    {{ teleputter "head" "unique-name" }} some html {{ teleputterend }}
    

    Content of this block goes to telepoint with appropriate telepoint name.

+2  A: 

This sounds like you are trying to implement template inheritance: http://docs.djangoproject.com/en/dev/topics/templates/#id1

Read the full documentation for the best explanation. The Readers Digest version follows.

Essentially you have a base template with blocks of content with default values:

base.html
{% block  head %} "Default html goes here"  {% endblock %}

Next you create another template that extends the base template and build the blocks you would like to replace:

anotherTemplate.html
{% extends "base.html %}
{% block  head %} "This replaces the html in the base head block"  {% endblock %}

It sounds to me that your "telepoint" is a block in the base template and your "teleputter" is a block that extends the base template

Does this sound like what you are trying to do? Is what you are trying to implement any different?

awithrow
I was already saying, that it looks like inheritance, but its notDifference:1. teleputter - could find telepoint from template that added as include2. block in inheritance could fill only one time3. inheritance means i will use only one child template, but I do components that I'll including
dynback.com