Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 May 21, 2010 21:50:56

Thomas A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Line continuation in block tag?


Is that possible in a Django template? If my tag spans more than one
line, it is rendered as plaintext.

Thomas

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 May 24, 2010 15:16:06

Thomas A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Line continuation in block tag?


Thomas Allen wrote:
> Is that possible in a Django template? If my tag spans more than one
> line, it is rendered as plaintext.

Is this not possible?

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 May 24, 2010 18:53:13

Dennis K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Line continuation in block tag?


On ma, 2010-05-24 at 07:15 -0700, Thomas Allen wrote:
> Thomas Allen wrote:
> > Is that possible in a Django template? If my tag spans more than one
> > line, it is rendered as plaintext.
>
> Is this not possible?

Correct. Tags should be on one line.

--
Dennis K.

They've gone to plaid!

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 June 14, 2010 15:56:55

Thomas A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Line continuation in block tag?


I have written certain custom tags that accept HTML attributes
(typically id and class), so they can often be verbose in usage. My
small idea was to write a tag that renders its contents as a tag, but
the trouble is that I cannot figure out how to parse the tag body.

For multi-line use of a tag "formtag," this wrapper would be used as
follows:

{% tag %}
formtag accounts.views.login id='test'
classes='this is a lengthy list of css classes'
{% endtag %}

As opposed to

{% formtag accounts.views.login id='test' classes='this is a lengthy
list of css classes' %}

In render() below, what might I do with the built token to parse it
normally? Parser.parse seems to contain the logic necessary to find
the tag function and create the correct Node type, but I'm not sure
how to use it on its own.

@register.tag(name='tag')
def do_tag(parser, token):
nodelist = parser.parse('endtag',)
parser.delete_first_token()
return TagNode(parser, nodelist)

class TagNode(template.Node):
def __init__(self, parser, nodelist):
self.parser = parser
self.nodelist = nodelist

def render(self, context):
tagbody = ' '.join(self.nodelist.render(context).splitlines())
token = template.Token(template.TOKEN_BLOCK, tagbody)
return ''


Thomas Allen

On May 24, 1:52 pm, Dennis Kaarsemaker <den...@kaarsemaker.net> wrote:
> On ma, 2010-05-24 at 07:15 -0700, Thomas Allen wrote:
>
> > Thomas Allen wrote:
> > > Is that possible in a Django template? If my tag spans more than one
> > > line, it is rendered as plaintext.
>
> > Is this not possible?
>
> Correct. Tags should be on one line.
>
> --
> Dennis K.
>
> They've gone to plaid!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group
> athttp://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support