I don't think it would be difficult to implement, either as a block tag, or as a regular tag with context.
On Jul 4, 7:29 pm, Ben Kovitz <[EMAIL PROTECTED]> wrote: > Is there an easy way in Django to do the following? > > In blah.html: > > <p>{{ buttonDecidedAtRunTime }} blah blah blah</p> > > In the Context passed to blah.html at run-time: > > buttonDecidedAtRunTime: '{% include "button4.html %}' > thisPage: "/some/path" > > Naturally, the included template might be button1.html, > button2.html, etc., depending on run-time decisions. > > In button4.html: > > <a href="{{ thisPage }}?action=button4action">html for button #4</ > a> > > The kicker is the {{ thisPage }} inside button4.html. I'm hoping to > pass thisPage in the context sent to blah.html. This would make the > code really simple. Of course, the code you see above will just show > the string literal '{% include "button4.html %}' right in your > browser. > > What's needed is something like eval for template tags. I could > imagine: > > {% eval %}{% buttonDecidedAtRunTime %}{% endeval %} > > or maybe even better would be: > > {% eval buttonDecidedAtRunTime %} > > Is there a way to do this? If it's not already in Django, does it > look easy to implement? I haven't yet implemented a custom tag, but I > read the chapter in the book, and it doesn't look too hard. On the > other hand, I don't want to spend days mired in it if it's hard. > > Or, is there a better way to do what I'm trying to do? Right now, I > see two other options: render button4.html and pass the result as the > value of buttonDecidedAtRunTime (this complicates the Python code a > bit, since thisPage must be passed to the subroutine that decides > which button to render); or use {% if %} tags in blah.html (kind of > ugly, involves difficulties with parameter-passing, and we need to do > this all over the place, though we could stuff the {% if %} logic into > an included template). > > Ben Kovitzhttp://decisionero.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---